This commit is contained in:
cesare 2023-01-10 12:41:24 +01:00
commit 042528001a
1 changed files with 297 additions and 156 deletions

View File

@ -1,24 +1,26 @@
/** /**
* *
*/ */
var resetResult; var resetResult;
$(document).ready(function() { $(document).ready(function() {
const categoriegrammaticali={"v":"Verbo", "s":"Sostantivo", "a":"Aggettivo", "p":"Pronome", "r":"Articolo", "b":"Avverbio","e":"Preposizione", const categoriegrammaticali = {
"c":"Congiunzione", "i":"Interiezione", "n":"Onomastica", "f":"Citazione", "l":"Locuzione", "v": "Verbo", "s": "Sostantivo", "a": "Aggettivo", "p": "Pronome", "r": "Articolo", "b": "Avverbio", "e": "Preposizione",
"r-e":"Articolo, Preposizione", "b-v":"Avverbio, Verbo", "p-v":"Pronome, Verbo", "c": "Congiunzione", "i": "Interiezione", "n": "Onomastica", "f": "Citazione", "l": "Locuzione",
"b-p-v":"Avverbio, Pronome, Verbo", "b-p":"Avverbio, Pronome", "r-e": "Articolo, Preposizione", "b-v": "Avverbio, Verbo", "p-v": "Pronome, Verbo",
"e-p":"Preposizione, Pronome", "a-s":"Aggettivo, Sostantivo", "b-p-v": "Avverbio, Pronome, Verbo", "b-p": "Avverbio, Pronome",
"e-r":"Preposizione, Articolo", "v-b":"Verbo, Avverbio", "v-p":"Verbo, Pronome", "e-p": "Preposizione, Pronome", "a-s": "Aggettivo, Sostantivo",
"v-p-b":"Verbo, Pronome, Avverbio", "p-b":"Pronome, Avverbio", "e-r": "Preposizione, Articolo", "v-b": "Verbo, Avverbio", "v-p": "Verbo, Pronome",
"p-e":"Pronome, Preposizione", "s-a":"Sostantivo, Aggettivo",} "v-p-b": "Verbo, Pronome, Avverbio", "p-b": "Pronome, Avverbio",
"p-e": "Pronome, Preposizione", "s-a": "Sostantivo, Aggettivo",
}
const cantobadgeclass = 'badge badge-outline-info badge-pill' const cantobadgeclass = 'badge badge-outline-info badge-pill'
const sparqlGenerator = sparqljs.Generator; const sparqlGenerator = sparqljs.Generator;
const myEngine = new Comunica.QueryEngine(); const myEngine = new Comunica.QueryEngine();
const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query"; const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query";
var listaVersi = new Set() var listaVersi = new Set()
var currentMinimap = '' var currentMinimap = ''
@ -26,7 +28,7 @@ $(document).ready(function() {
var minimapScrolling = false; var minimapScrolling = false;
var displayId = 'displaycanto' var displayId = 'displaycanto'
var minimapTopPos; var minimapTopPos;
//used in minimap //used in minimap
// //
let minimap = document.createElement('div'); let minimap = document.createElement('div');
@ -37,43 +39,91 @@ $(document).ready(function() {
let realScale; let realScale;
let mappedElement = ''; let mappedElement = '';
resetResult=function(){ var purgatorioSelected = "PurgatorioCanto_1";
var paradisoSelected = "ParadisoCanto_1";
var infernoSelected = "InfernoCanto_1";
resetResult = function() {
//console.log('clean result') //console.log('clean result')
cleanSearchResult() cleanSearchResult()
esprlogica = [] esprlogica = []
} }
hideMinimap(); hideMinimap();
createAllDivCanti() createAllDivCanti()
const start = performance.now(); const start = performance.now();
showCantica('Inferno') showCantica('Inferno')
showCantica('Purgatorio') var purgatorioLoaded = false;
showCantica('Paradiso') var paradisoLoaded = false;
$("#InfernoCanto_1").attr('style', 'display:block') $("#InfernoCanto_1").attr('style', 'display:block')
drawMinimap("InfernoCanto_1") drawMinimap("InfernoCanto_1")
const end = performance.now(); const end = performance.now();
console.log(`Load cantiche time: ${end - start} ms`); console.log(`Load cantiche time: ${end - start} ms`);
jQuery(document).delegate('#cantica2', 'click', function(e) {
e.preventDefault();
if (!purgatorioLoaded){
showCantica('Purgatorio')
purgatorioLoaded = true;
}
$('.canto').each(function() {
$(this).attr("style", 'display:none');
});
$("#"+purgatorioSelected).attr('style', 'display:block')
manageMiniMap("#"+purgatorioSelected);
return true;
});
jQuery(document).delegate('#cantica3', 'click', function(e) {
e.preventDefault();
if (!paradisoLoaded){
showCantica('Paradiso')
paradisoLoaded = true;
}
$('.canto').each(function() {
$(this).attr("style", 'display:none');
});
$("#"+paradisoSelected).attr('style', 'display:block')
manageMiniMap("#"+paradisoSelected);
return true;
});
jQuery(document).delegate('#cantica1', 'click', function(e) {
e.preventDefault();
$('.canto').each(function() {
$(this).attr("style", 'display:none');
});
$("#"+infernoSelected).attr('style', 'display:block')
manageMiniMap("#"+infernoSelected);
return true;
});
$("[data-cg]").hover(function() { $("[data-cg]").hover(function() {
var details=getHoverContent($(this).data("cg")) var details = getHoverContent($(this).data("cg"))
var index = details.indexOf(","); var index = details.indexOf(",");
var categoria = ""; var categoria = "";
if (index != -1){ if (index != -1) {
categoria = details.substring(0,index); categoria = details.substring(0, index);
details = details.substring(index+1); details = details.substring(index + 1);
}else{ } else {
categoria = details; categoria = details;
details = ""; details = "";
} }
$(this).popover({title: categoria, content: details, trigger: "click"}); $(this).popover({ title: categoria, content: details, trigger: "click" });
}); });
var mmih = 0 var mmih = 0
var mmiw = 0 var mmiw = 0
$("#" + displayId).scroll(function() { $("#" + displayId).scroll(function() {
if (minimapScrolling) { if (minimapScrolling) {
minimapScrolling = false minimapScrolling = false
@ -95,22 +145,31 @@ $(document).ready(function() {
// Crea id per la div che contiene il canto // Crea id per la div che contiene il canto
$("#" + $(this).attr('name').replace(" ", "_")).attr('style', 'display:block') $("#" + $(this).attr('name').replace(" ", "_")).attr('style', 'display:block')
manageMiniMap(this); manageMiniMap(this);
}); });
function manageMiniMap(divElem) { function manageMiniMap(divElem) {
mmiw = $("#" + displayId).innerWidth(); mmiw = $("#" + displayId).innerWidth();
mmih = $("#" + displayId).innerHeight(); mmih = $("#" + displayId).innerHeight();
var selectedCanto = ($(divElem).attr('name').replace(" ", "_"));
if (selectedCanto.startsWith("Inferno")){
infernoSelected = selectedCanto;
}else
if(selectedCanto.startsWith("Paradiso")){
paradisoSelected = selectedCanto;
}else{
purgatorioSelected = selectedCanto;
}
drawMinimap($(divElem).attr('name').replace(" ", "_")) drawMinimap($(divElem).attr('name').replace(" ", "_"))
} }
//Query //Query
jQuery(document).delegate('#searchcomm, #searchcomm2', 'click', function(e) { jQuery(document).delegate('#searchcomm, #searchcomm2', 'click', function(e) {
e.preventDefault(); e.preventDefault();
manageQuery() manageQuery()
}); });
//Reset //Reset
@ -121,47 +180,56 @@ $(document).ready(function() {
$('#queryText').val("") $('#queryText').val("")
}); });
//Utility functions //Utility functions
function getHoverContent(categ){ function getHoverContent(categ) {
//console.log('Categoria '+categ) //console.log('Categoria '+categ)
if(categ.includes('-')){ if (categ.includes('-')) {
categs=categ.split('-') categs = categ.split('-')
mycat=[] mycat = []
for (cat of categs){ for (cat of categs) {
mycat.push(cat[0]) mycat.push(cat[0])
} }
console.log(mycat.join('-')) console.log(mycat.join('-'))
return categoriegrammaticali[mycat.join('-')] return categoriegrammaticali[mycat.join('-')]
} }
if (categ[0]=='v'){ if (categ[0] == 'v') {
return parserVerbi.parse(categ).split(',').filter(prop => prop.length > 0).join() return parserVerbi.parse(categ).split(',').filter(prop => prop.length > 0).join()
} }
if(categ[0]=='s'){ if (categ[0] == 's') {
return parserSostantivi.parse(categ).split(',').filter(prop => prop.length > 0).join() return parserSostantivi.parse(categ).split(',').filter(prop => prop.length > 0).join()
} }
if(categ[0]=='e'){ if (categ[0] == 'e') {
return parserPreposizioni.parse(categ).split(',').filter(prop => prop.length > 0).join() return parserPreposizioni.parse(categ).split(',').filter(prop => prop.length > 0).join()
} }
if(categ[0]=='b'){ if (categ[0] == 'b') {
return parserAvverbi.parse(categ).split(',').filter(prop => prop.length > 0).join() return parserAvverbi.parse(categ).split(',').filter(prop => prop.length > 0).join()
} }
if(categ[0]=='p'){ if (categ[0] == 'p') {
return parserPronomi.parse(categ).split(',').filter(prop => prop.length > 0).join() return parserPronomi.parse(categ).split(',').filter(prop => prop.length > 0).join()
} }
if(categ[0]=='a'){ if (categ[0] == 'a') {
return parserAggettivi.parse(categ).split(',').filter(prop => prop.length > 0).join() return parserAggettivi.parse(categ).split(',').filter(prop => prop.length > 0).join()
} }
if(categ[0]=='r'){ if (categ[0] == 'r') {
return parserArticolo.parse(categ).split(',').filter(prop => prop.length > 0).join() return parserArticolo.parse(categ).split(',').filter(prop => prop.length > 0).join()
} }
if (categ[0] == 'f') {
return parserCitazione.parse(categ).split(',').filter(prop => prop.length > 0).join();
}
if (categ[0] == 'n') {
return parserOnomastica.parse(categ).split(',').filter(prop => prop.length > 0).join();
}
if (categ[0] == 'c') {
return parserCongiunzione.parse(categ).split(',').filter(prop => prop.length > 0).join();
}
//console.log(categ[0]) //console.log(categ[0])
return categoriegrammaticali[categ[0]] return categoriegrammaticali[categ[0]]
} }
function drawMinimap(name){ function drawMinimap(name) {
showMinimap(name) showMinimap(name)
currentMinimap = name; currentMinimap = name;
@ -183,7 +251,7 @@ $(document).ready(function() {
} }
}); });
} }
function cleanSearchResult() { function cleanSearchResult() {
for (verso of listarisultati) { for (verso of listarisultati) {
@ -195,25 +263,25 @@ $(document).ready(function() {
if (currentMinimap != '') if (currentMinimap != '')
showMinimap(currentMinimap) showMinimap(currentMinimap)
} }
function manageQuery(){ function manageQuery() {
cleanSearchResult() cleanSearchResult()
esprlogica = [] esprlogica = []
jsonQuery=getJsonQuery() jsonQuery = getJsonQuery()
console.log("got json query") console.log("got json query")
if(jsonQuery['QueryAvanzata']==0 && jsonQuery['Clausola0']['queryText']==''){ if (jsonQuery['QueryAvanzata'] == 0 && jsonQuery['Clausola0']['queryText'] == '') {
alert('Digitare una stringa da cercare') alert('Digitare una stringa da cercare')
return return
} }
jsonQuery = buildSQ(jsonQuery) jsonQuery = buildSQ(jsonQuery)
myquery = new sparqlGenerator().stringify(jsonQuery) myquery = new sparqlGenerator().stringify(jsonQuery)
console.log(myquery) console.log(myquery)
executeQuerySearch(myquery) executeQuerySearch(myquery)
} }
//minimap management //minimap management
function showMinimap(element) { function showMinimap(element) {
mmplace = document.getElementById('displayminimap') mmplace = document.getElementById('displayminimap')
@ -257,21 +325,21 @@ $(document).ready(function() {
function getInnerHeight(elm) { function getInnerHeight(elm) {
var computed = getComputedStyle(elm), var computed = getComputedStyle(elm),
padding = parseInt(computed.paddingTop) + parseInt(computed.paddingBottom); padding = parseInt(computed.paddingTop) + parseInt(computed.paddingBottom);
return elm.clientHeight - padding return elm.clientHeight - padding
} }
function getDimensionsDiv() { function getDimensionsDiv() {
var cantoplace = document.getElementById(displayId) var cantoplace = document.getElementById(displayId)
var elementplace = document.getElementById(mappedElement) var elementplace = document.getElementById(mappedElement)
var bodyWidth = elementplace.clientWidth; var bodyWidth = elementplace.clientWidth;
var bodyRatio = elementplace.clientHeight / bodyWidth; var bodyRatio = elementplace.clientHeight / bodyWidth;
let winRatio = getInnerHeight(cantoplace) / (cantoplace.clientWidth); let winRatio = getInnerHeight(cantoplace) / (cantoplace.clientWidth);
//minimap.style.width='15%'; //minimap.style.width='15%';
@ -283,7 +351,7 @@ $(document).ready(function() {
viewer.style.paddingTop = `${winRatio * 100}%`; viewer.style.paddingTop = `${winRatio * 100}%`;
minimapContent.style.transform = `scale(${realScale})`; minimapContent.style.transform = `scale(${realScale})`;
minimapContent.style.width = `${(100 / realScale)}%`; minimapContent.style.width = `${(100 / realScale)}%`;
minimapContent.style.height = `${(100 / realScale)}%`; minimapContent.style.height = `${(100 / realScale)}%`;
//minimapContent.style.height=`100%`; //minimapContent.style.height=`100%`;
minimapContent.style.float = 'right'; minimapContent.style.float = 'right';
} }
@ -311,7 +379,7 @@ $(document).ready(function() {
currentMinimap = '' currentMinimap = ''
} }
//Cantica management functions //Cantica management functions
function showCantica(cantica) { function showCantica(cantica) {
@ -324,22 +392,22 @@ $(document).ready(function() {
if (cantica == 'Purgatorio') if (cantica == 'Purgatorio')
containerForme = formeseconda containerForme = formeseconda
const endlc = performance.now(); const endlc = performance.now();
console.log(`Load `+cantica+` time: ${endlc - start} ms`); console.log(`Load ` + cantica + ` time: ${endlc - start} ms`);
var elverso, formaItem var elverso, formaItem
for (var cmpItem of containerForme) { for (var cmpItem of containerForme) {
formaItem = cmpItem.split("_") formaItem = cmpItem.split("_")
//createDivVerso(cantica, num, canto, forma, catgram, pos) //createDivVerso(cantica, num, canto, forma, catgram, pos)
if (! setVersi.has(cantica + "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1])){ if (!setVersi.has(cantica + "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1])) {
elverso=createDivVerso(cantica, formaItem[3], 'Canto_' + formaItem[1], formaItem[0], formaItem[4], formaItem[2]) elverso = createDivVerso(cantica, formaItem[3], 'Canto_' + formaItem[1], formaItem[0], formaItem[4], formaItem[2])
setVersi.add(cantica+ "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1]) setVersi.add(cantica + "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1])
} }
else{ else {
//setVersi = createDivVersi(setVersi, cantica, formaItem[3], 'Canto_' + formaItem[1]) //setVersi = createDivVersi(setVersi, cantica, formaItem[3], 'Canto_' + formaItem[1])
createSpanFormeNew(cantica, 'Canto_' + formaItem[1], formaItem[3], formaItem[0], formaItem[4], formaItem[2], elverso) createSpanFormeNew(cantica, 'Canto_' + formaItem[1], formaItem[3], formaItem[0], formaItem[4], formaItem[2], elverso)
} }
/* /*
forma.numverso = formaItem[3]; forma.numverso = formaItem[3];
forma.canto = 'Canto ' + formaItem[1]; forma.canto = 'Canto ' + formaItem[1];
@ -369,21 +437,21 @@ $(document).ready(function() {
} }
*/ */
function createSpanFormeNew(cantica, canto, numverso, forma, catgramm, pos, elementoverso) { function createSpanFormeNew(cantica, canto, numverso, forma, catgramm, pos, elementoverso) {
var spanoccorrenza = $('<span />') var spanoccorrenza = $('<span />')
//var pos = parseInt(pos) //var pos = parseInt(pos)
spanoccorrenza.attr('id', cantica + "_" + canto+ "_" + numverso + "_" + pos) spanoccorrenza.attr('id', cantica + "_" + canto + "_" + numverso + "_" + pos)
spanoccorrenza.attr('data-cg', catgramm) spanoccorrenza.attr('data-cg', catgramm)
//if (listarisultati.length > 0 && listarisultati.includes(spanoccorrenza.attr('id'))) //if (listarisultati.length > 0 && listarisultati.includes(spanoccorrenza.attr('id')))
// spanoccorrenza.attr('class', "font-weight-bold mark ") // spanoccorrenza.attr('class', "font-weight-bold mark ")
spanoccorrenza.append(forma+" ") spanoccorrenza.append(forma + " ")
//elementoverso = $('#' + cantica + "_" + canto + "_" + numverso) //elementoverso = $('#' + cantica + "_" + canto + "_" + numverso)
spanoccorrenza.appendTo(elementoverso) spanoccorrenza.appendTo(elementoverso)
//elementoverso.append('&nbsp;') //elementoverso.append('&nbsp;')
} }
function createDivVersi(setVersi, cantica, num, canto) { function createDivVersi(setVersi, cantica, num, canto) {
if (setVersi.has(cantica + "_" + num + "_" + canto)) if (setVersi.has(cantica + "_" + num + "_" + canto))
return setVersi return setVersi
@ -403,54 +471,33 @@ $(document).ready(function() {
} }
function createDivVerso(cantica, num, canto, forma, catgram, pos) { function createDivVerso(cantica, num, canto, forma, catgram, pos) {
var elementoverso = $('<p />')
elementoverso.append(num + ". ") var elementoverso = $('<p />')
elementoverso.attr("style", "line-height: 0.5em")
elementoverso.attr('class', 'f6 text-secondary text-nowrap font-weight-lighter') elementoverso.append(num + ". ")
elementoverso.attr("style", "line-height: 0.5em")
elementoverso.attr('id', cantica + "_" + canto + "_" + num) elementoverso.attr('class', 'f6 text-secondary text-nowrap font-weight-lighter')
var spanoccorrenza = $('<span />') elementoverso.attr('id', cantica + "_" + canto + "_" + num)
//var pos = parseInt(pos)
spanoccorrenza.attr('id', cantica + "_" + canto+ "_" + num + "_" + pos) var spanoccorrenza = $('<span />')
spanoccorrenza.attr('data-cg', catgram) //var pos = parseInt(pos)
spanoccorrenza.attr('id', cantica + "_" + canto + "_" + num + "_" + pos)
spanoccorrenza.append(forma+" ") spanoccorrenza.attr('data-cg', catgram)
spanoccorrenza.appendTo(elementoverso)
spanoccorrenza.append(forma + " ")
elementoverso.appendTo('#' + cantica + canto) spanoccorrenza.appendTo(elementoverso)
return elementoverso
elementoverso.appendTo('#' + cantica + canto)
return elementoverso
} }
/* /*
function createDivCanti(orderedListaCanti, cantica, canto) { function createDivCanti(orderedListaCanti, cantica, canto) {
if (orderedListaCanti.has(canto)) { if (orderedListaCanti.has(canto)) {
return orderedListaCanti return orderedListaCanti
} }
var divcanto = $('<div />')
var titolocanto = $('<h4 class="titolo-canto pb-2" />')
titolocanto.append(cantica + ", " + canto)
divcanto.attr('class', 'canto')
divcanto.attr('style', 'display:none')
divcanto.attr('id', (cantica + canto).replace(" ", "_"))
titolocanto.appendTo(divcanto)
divcanto.appendTo(' .blog-main')
orderedListaCanti.add(canto)
return orderedListaCanti
}
*/
function createAllDivCanti() {
cantiche=["Inferno", "Purgatorio","Paradiso"]
for (cantica of cantiche){
for (var i=1; i<35; i++){
if(i==34 && cantica!=="Inferno"){
continue
}
canto= "Canto "+i
var divcanto = $('<div />') var divcanto = $('<div />')
var titolocanto = $('<h4 class="titolo-canto pb-2" />') var titolocanto = $('<h4 class="titolo-canto pb-2" />')
titolocanto.append(cantica + ", " + canto) titolocanto.append(cantica + ", " + canto)
@ -459,13 +506,34 @@ $(document).ready(function() {
divcanto.attr('id', (cantica + canto).replace(" ", "_")) divcanto.attr('id', (cantica + canto).replace(" ", "_"))
titolocanto.appendTo(divcanto) titolocanto.appendTo(divcanto)
divcanto.appendTo(' .blog-main') divcanto.appendTo(' .blog-main')
orderedListaCanti.add(canto)
return orderedListaCanti
}
*/
function createAllDivCanti() {
cantiche = ["Inferno", "Purgatorio", "Paradiso"]
for (cantica of cantiche) {
for (var i = 1; i < 35; i++) {
if (i == 34 && cantica !== "Inferno") {
continue
}
canto = "Canto " + i
var divcanto = $('<div />')
var titolocanto = $('<h4 class="titolo-canto pb-2" />')
titolocanto.append(cantica + ", " + canto)
divcanto.attr('class', 'canto')
divcanto.attr('style', 'display:none')
divcanto.attr('id', (cantica + canto).replace(" ", "_"))
titolocanto.appendTo(divcanto)
divcanto.appendTo(' .blog-main')
} }
} }
} }
//execute query //execute query
async function executeQuerySearch(query) { async function executeQuerySearch(query) {
$("#loader").show(); $("#loader").show();
seachbBindingsStream = await myEngine.queryBindings(query, { sources: [{ type: 'sparql', value: sparqlEndpoint },], }); seachbBindingsStream = await myEngine.queryBindings(query, { sources: [{ type: 'sparql', value: sparqlEndpoint },], });
@ -478,20 +546,20 @@ $(document).ready(function() {
seachbBindingsStream.on('data', (binding) => { seachbBindingsStream.on('data', (binding) => {
//cantica //cantica
cantica = binding.get('Cantica').value; cantica = binding.get('Cantica').value;
//canto //canto
canto = binding.get('Canto').value; canto = binding.get('Canto').value;
//numero del verso //numero del verso
numverso = binding.get('NumeroVerso').value; numverso = binding.get('NumeroVerso').value;
//posizione del frammento //posizione del frammento
pos = binding.get('pos').value; pos = binding.get('pos').value;
if (!result.has(cantica + "_" + canto.replace(" ", "_") + "_" + numverso + "_" + pos)){ if (!result.has(cantica + "_" + canto.replace(" ", "_") + "_" + numverso + "_" + pos)) {
result.add(cantica + "_" + canto.replace(" ", "_") + "_" + numverso + "_" + pos) result.add(cantica + "_" + canto.replace(" ", "_") + "_" + numverso + "_" + pos)
resultsInCantica.push(cantica); resultsInCantica.push(cantica);
resultsInCanto.push(cantica + canto) resultsInCanto.push(cantica + canto)
} }
}); });
seachbBindingsStream.on('end', () => { seachbBindingsStream.on('end', () => {
@ -509,7 +577,7 @@ $(document).ready(function() {
for (cantica of cantiche) { for (cantica of cantiche) {
i += 1 i += 1
let count = resultsInCantica.reduce((n, x) => n + (x === cantica), 0); let count = resultsInCantica.reduce((n, x) => n + (x === cantica), 0);
if (count>0){ if (count > 0) {
var spanbadgecantica = $('<span />'); var spanbadgecantica = $('<span />');
spanbadgecantica.attr('class', 'badge badge-primary badge-pill ml-1'); spanbadgecantica.attr('class', 'badge badge-primary badge-pill ml-1');
spanbadgecantica.append(count) spanbadgecantica.append(count)
@ -523,7 +591,7 @@ $(document).ready(function() {
if (k == 0) if (k == 0)
continue continue
let count = resultsInCanto.reduce((n, x) => n + (x === cantica + 'Canto ' + k), 0); let count = resultsInCanto.reduce((n, x) => n + (x === cantica + 'Canto ' + k), 0);
if (count>0){ if (count > 0) {
var spanbadge = $('<span />'); var spanbadge = $('<span />');
spanbadge.attr('class', cantobadgeclass); spanbadge.attr('class', cantobadgeclass);
spanbadge.append(count) spanbadge.append(count)
@ -551,22 +619,21 @@ $(document).ready(function() {
}; };
/* /*
* REGOLE DI PARSING PER VISUALIZZAZIONE PROPRIETÀ * REGOLE DI PARSING PER VISUALIZZAZIONE PROPRIETÀ
*/ */
var categoriegrammaticaliGrammar=`Expression = head:(Filtro){return 'Verbo,'+head.join()} var categoriegrammaticaliGrammar = `Expression = head:(Filtro){return 'Verbo,'+head.join()}
Filtro= fhead:("v")? tail:( transitivita? diatesi? impersonalita? Filtro= fhead:("v") tail:( transitivita? diatesi? impersonalita*
coniugazione? modotempo? coniugazione? modotempo?
persona? funzione? declinazione? persona? funzione* declinazione?
genere? numero? grado?){return tail} genere? numero? grado?){return tail}
diatesi= [a|p] {if (text()=='a') return ' Attivo'; else return ' Passivo';} diatesi= [a|p] {if (text()=='a') return ' Attivo'; else return ' Passivo';}
transitivita=[i|t]? {if (text()=='t') return ' Transitivo'; else if (text()=='i') return ' Intransitivo';} transitivita=[i|t]? {if (text()=='t') return ' Transitivo'; else if (text()=='i') return ' Intransitivo';}
impersonalita=([*|+])? {if (text()=='*') return ' Impersonale'; else if (text()=='+')return ' Riflessivo';} impersonalita=([*|+]) {if (text()=='*') return ' Impersonale'; else if (text()=='+')return ' Riflessivo';}
coniugazione=[1|2|3|4|5]? {switch(parseInt(text())){ coniugazione=[1|2|3|4|5]? {switch(parseInt(text())){
case(1): return ' Prima coniugazione'; case(1): return ' Prima coniugazione';
@ -633,9 +700,9 @@ _ "whitespace"= " "*
` `
var categoriaGrammaticaleSostantivo = ` var categoriaGrammaticaleSostantivo = `
Expression = head:(Filtro){return 'Sostantivo,'+head.join()} Expression = head:(Filtro){return 'Sostantivo,'+head.join()}
Filtro= fhead:("s")? tail:( genereforma? declinazionesostantivo? generelemma? Filtro= fhead:("s") tail:( genereforma? declinazionesostantivo? generelemma?
numersingolareplurale? locuzione?){return tail} numersingolareplurale? locuzione?){return tail}
@ -650,7 +717,7 @@ generelemma=[m|f]? {if (text()=='m') return ' lemma maschile'; else if (text()==
numersingolareplurale=[s|p]? {if (text()=='s') return ' numero singolare'; else if (text()=='p') return ' numero plurale';} numersingolareplurale=[s|p]? {if (text()=='s') return ' numero singolare'; else if (text()=='p') return ' numero plurale';}
locuzione="Iv" {return('In Locuzione verbo');} locuzione="lv" {return('In Locuzione verbo');}
Integer "integer" Integer "integer"
= _ [0-9]+ { return parseInt(text(), 10); } = _ [0-9]+ { return parseInt(text(), 10); }
@ -659,9 +726,9 @@ _ "whitespace"= " "*
` `
var categoriaGrammaticalePreposizione = ` var categoriaGrammaticalePreposizione = `
Expression = head:(Filtro){return 'Preposizione,'+head.join()} Expression = head:(Filtro){return 'Preposizione,'+head.join()}
Filtro= fhead:("e")? tail:( tipo1? tipo2? sintassi? complemento1? complemento2?){return tail} Filtro= fhead:("e") tail:( tipo1? tipo2? sintassi? complemento1? complemento2?){return tail}
tipo1=[p|i] {if (text()=='i') return ' Impropria'; else if (text()=='p') return ' Impropria';} tipo1=[p|i] {if (text()=='i') return ' Impropria'; else if (text()=='p') return ' Impropria';}
@ -741,17 +808,16 @@ complemento2=
"k14" {return(" Di Rapporto")} "k14" {return(" Di Rapporto")}
` `
var avverbio = ` Expression = head:(Filtro){return 'Avverbio,'+head.join()} var avverbio = `Expression = head:(Filtro){return 'Avverbio,'+head.join()}
Filtro= fhead:("b")? tail:( fake? tipo?){return tail} Filtro= fhead:("b") tail:( locuzione? tipo?){return tail}
fake= "" locuzione = "lz" {return(' Avverbio in Locuzione Separato')}/
"l" {return(' Avverbio in Locuzione')}
tipo="c+" {return(' Avverbio al Comparativo di Maggioranza')}/ tipo="c+" {return(' Avverbio al Comparativo di Maggioranza')}/
"c-" {return(' Avverbio al Comparativo di Minoranza')}/ "c-" {return(' Avverbio al Comparativo di Minoranza')}/
"sa" {return(' Avverbio al Superlativo Assoluto')}/ "sa" {return(' Avverbio al Superlativo Assoluto')}/
"sr" {return(' Avverbio al Superlativo Relativo')}/ "sr" {return(' Avverbio al Superlativo Relativo')}/
"lz" {return(' Avverbio in Locuzione Separato')}/
"l" {return(' Avverbio in Locuzione')}/
"y" {return(' Avverbio Proclitico')}/ "y" {return(' Avverbio Proclitico')}/
"x" {return(' Avverbio Enclitico')}/ "x" {return(' Avverbio Enclitico')}/
"c" {return(' Avverbio al Comparativo di Uguaglianza')} "c" {return(' Avverbio al Comparativo di Uguaglianza')}
@ -762,12 +828,11 @@ Integer "integer"
_ "whitespace"= " "* _ "whitespace"= " "*
` `
var pronome = ` var pronome = `Expression = head:(Filtro){return 'Pronome,'+head.join()}
Filtro= fhead:("p") tail:( tipo_pronome? classe_pronome? genere_pronome?
Expression = head:(Filtro){return 'Pronome,'+head.join()}
Filtro= fhead:("p")? tail:( tipo_pronome? classe_pronome? genere_pronome?
numero_pronome? forma_pronome? funzione_pronome? tiporiflessivi?){return tail} numero_pronome? forma_pronome? funzione_pronome? tiporiflessivi?){return tail}
@ -794,8 +859,8 @@ forma_pronome= "l" {return(" Pronome Libero")}/
"i" {return(" Pronome Libero In Composizione")}/ "i" {return(" Pronome Libero In Composizione")}/
"y" {return(" Pronome Proclitico")}/ "y" {return(" Pronome Proclitico")}/
"x" {return(" Pronome Enclitico")} "x" {return(" Pronome Enclitico")}
funzione_pronome="so" {return(' Libero Soggetto')}/ funzione_pronome= "soi" {return(' Libero Soggetto Impersonale')}/
"soi" {return(' Libero Soggetto Impersonale')}/ "so" {return(' Libero Soggetto')}/
"co" {return(' Libero Complemento')}/ "co" {return(' Libero Complemento')}/
"ra" {return(' Libero Rafforzativo')}/ "ra" {return(' Libero Rafforzativo')}/
"ac" {return(' Clitico Accusativo')}/ "ac" {return(' Clitico Accusativo')}/
@ -816,9 +881,9 @@ Integer "integer"
_ "whitespace"= " "* _ "whitespace"= " "*
` `
var categoriaGrammaticaleAggettivo = ` var categoriaGrammaticaleAggettivo = `
Expression = head:(Filtro){return 'Aggettivo,'+head.join()} Expression = head:(Filtro){return 'Aggettivo,'+head.join()}
Filtro= fhead:("a")? tail:( tipo_aggettivo classe_aggettivo? genere_aggettivo? Filtro= fhead:("a") tail:( tipo_aggettivo classe_aggettivo? genere_aggettivo?
numero_aggettivo? grado_aggettivo? tipo_complemento? tipo_frase? numero_aggettivo? grado_aggettivo? tipo_complemento? tipo_frase?
oggetto_indiretto?){return tail} oggetto_indiretto?){return tail}
@ -899,10 +964,10 @@ Integer "integer"
_ "whitespace"= " "* _ "whitespace"= " "*
` `
var categoriaGrammaticaleArticolo = ` var categoriaGrammaticaleArticolo = `
Expression = head:(Filtro){return 'Articolo,'+head.join()} Expression = head:(Filtro){return 'Articolo,'+head.join()}
Filtro= fhead:("r")? tail:( tipo? genere? numero?){return tail} Filtro= fhead:("r") tail:( tipo? genere? numero?){return tail}
tipo = tipo =
"d" {return(" Determinativo")}/ "d" {return(" Determinativo")}/
@ -924,15 +989,91 @@ _ "whitespace"= " "*
` `
var citazione = `
Expression = head:(Filtro){return 'Citazione,'+head.join()}
Filtro= fhead:("f") tail:( fake? tipo?){return tail}
//parser per categorie fake = ""
var parserVerbi = peg.generate(categoriegrammaticaliGrammar); tipo="l" {return(' Citazione Latina')}/
var parserSostantivi = peg.generate(categoriaGrammaticaleSostantivo); "p" {return(' Citazione Provenzale')}/
var parserPreposizioni = peg.generate(categoriaGrammaticalePreposizione); "r" {return(' Citazione Francese')}/
var parserAvverbi = peg.generate(avverbio); "s" {return(' Citazione Spagnola')}/
var parserPronomi = peg.generate(pronome); "e" {return(' Citazione Ebraica')}/
var parserAggettivi = peg.generate(categoriaGrammaticaleAggettivo); "g" {return(' Citazione Greca')}
var parserArticolo = peg.generate(categoriaGrammaticaleArticolo);
Integer "integer"
= _ [0-9]+ { return parseInt(text(), 10); }
_ "whitespace"= " "*
`
var onomastica = `Expression = head:(Filtro){return 'Onomastica,'+head.join()}
Filtro= fhead:("n") tail:( proprio tipo?){return tail}
tipo="x" {return(' Separato')}/
"t" {return(' Titolo')}
proprio = "p" {return("Nome Proprio")}
Integer "integer"
= _ [0-9]+ { return parseInt(text(), 10); }
_ "whitespace"= " "*
`
var congiunzione = `
Expression = head:(Filtro){return 'Congiunzione,'+head.join()}
Filtro= fhead:("c") tail:( tipo? cordinativasubordinativa? tipocoordinativa?
tiposubordinativa* complementodue?){return tail}
tipo = "lx" {return(' Semplice')}/
"c" {return(" Composta")}/
"l" {return(" Locuzione")}/
"s" {return(" LocuzioneSeparata")}
cordinativasubordinativa = "c" {return(" Coordinativa")}/
"s" {return(" Subordinativa")}
tipocoordinativa = "c" {return(" Copulativa")}/
"d" {return(" Disgiuntiva")}/
"a" {return(" Avversativa")}/
"n" {return(" Conclusiva")}/
"e" {return(" Esplicativa")}/
"r" {return(" Correlativa")}
tiposubordinativa = "s" {return(" Soggettiva")}/
"o" {return(" Oggettiva")}/
"d" {return(" Dichiarativa")}/
"b" {return(" Completiva Obliqua")}/
"i" {return(" Interrogativa")}/
"f" {return(" Finali")}/
"c" {return(" Causali")}/
"n" {return(" Concessiva")}/
"u" {return(" Consecutiva")}/
"t" {return(" Temporale")}/
"m" {return(" Modale")}/
"e" {return(" Eccettuativa")}/
"p" {return(" Comparativa")}/
"v" {return(" Condizionale")}/
"z" {return(" Esclusiva")}/
"l" {return(" Limitativa")}
complementodue =
"x" {return(" Locuzione Separata")}
Integer "integer"
= _ [0-9]+ { return parseInt(text(), 10); }
_ "whitespace"= " "*
`
//parser per categorie
var parserVerbi = peg.generate(categoriegrammaticaliGrammar);
var parserSostantivi = peg.generate(categoriaGrammaticaleSostantivo);
var parserPreposizioni = peg.generate(categoriaGrammaticalePreposizione);
var parserAvverbi = peg.generate(avverbio);
var parserPronomi = peg.generate(pronome);
var parserAggettivi = peg.generate(categoriaGrammaticaleAggettivo);
var parserArticolo = peg.generate(categoriaGrammaticaleArticolo);
var parserCitazione = peg.generate(citazione);
var parserOnomastica = peg.generate(onomastica);
var parserCongiunzione = peg.generate(congiunzione);
}); });