diff --git a/js/cesareBrowse.js b/js/cesareBrowse.js index 342512a..b62947b 100644 --- a/js/cesareBrowse.js +++ b/js/cesareBrowse.js @@ -1,24 +1,26 @@ /** * */ - var resetResult; - +var resetResult; + $(document).ready(function() { - const categoriegrammaticali={"v":"Verbo", "s":"Sostantivo", "a":"Aggettivo", "p":"Pronome", "r":"Articolo", "b":"Avverbio","e":"Preposizione", - "c":"Congiunzione", "i":"Interiezione", "n":"Onomastica", "f":"Citazione", "l":"Locuzione", - "r-e":"Articolo, Preposizione", "b-v":"Avverbio, Verbo", "p-v":"Pronome, Verbo", - "b-p-v":"Avverbio, Pronome, Verbo", "b-p":"Avverbio, Pronome", - "e-p":"Preposizione, Pronome", "a-s":"Aggettivo, Sostantivo", - "e-r":"Preposizione, Articolo", "v-b":"Verbo, Avverbio", "v-p":"Verbo, Pronome", - "v-p-b":"Verbo, Pronome, Avverbio", "p-b":"Pronome, Avverbio", - "p-e":"Pronome, Preposizione", "s-a":"Sostantivo, Aggettivo",} + const categoriegrammaticali = { + "v": "Verbo", "s": "Sostantivo", "a": "Aggettivo", "p": "Pronome", "r": "Articolo", "b": "Avverbio", "e": "Preposizione", + "c": "Congiunzione", "i": "Interiezione", "n": "Onomastica", "f": "Citazione", "l": "Locuzione", + "r-e": "Articolo, Preposizione", "b-v": "Avverbio, Verbo", "p-v": "Pronome, Verbo", + "b-p-v": "Avverbio, Pronome, Verbo", "b-p": "Avverbio, Pronome", + "e-p": "Preposizione, Pronome", "a-s": "Aggettivo, Sostantivo", + "e-r": "Preposizione, Articolo", "v-b": "Verbo, Avverbio", "v-p": "Verbo, Pronome", + "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 sparqlGenerator = sparqljs.Generator; const myEngine = new Comunica.QueryEngine(); const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query"; - + var listaVersi = new Set() var currentMinimap = '' @@ -26,7 +28,7 @@ $(document).ready(function() { var minimapScrolling = false; var displayId = 'displaycanto' var minimapTopPos; - + //used in minimap // let minimap = document.createElement('div'); @@ -37,43 +39,91 @@ $(document).ready(function() { let realScale; let mappedElement = ''; - resetResult=function(){ + var purgatorioSelected = "PurgatorioCanto_1"; + var paradisoSelected = "ParadisoCanto_1"; + var infernoSelected = "InfernoCanto_1"; + + + resetResult = function() { //console.log('clean result') cleanSearchResult() esprlogica = [] } - + hideMinimap(); createAllDivCanti() const start = performance.now(); + showCantica('Inferno') - showCantica('Purgatorio') - showCantica('Paradiso') + var purgatorioLoaded = false; + var paradisoLoaded = false; + $("#InfernoCanto_1").attr('style', 'display:block') drawMinimap("InfernoCanto_1") const end = performance.now(); 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() { - var details=getHoverContent($(this).data("cg")) + var details = getHoverContent($(this).data("cg")) var index = details.indexOf(","); var categoria = ""; - if (index != -1){ - categoria = details.substring(0,index); - details = details.substring(index+1); - }else{ + if (index != -1) { + categoria = details.substring(0, index); + details = details.substring(index + 1); + } else { categoria = details; details = ""; } - $(this).popover({title: categoria, content: details, trigger: "click"}); + $(this).popover({ title: categoria, content: details, trigger: "click" }); }); var mmih = 0 var mmiw = 0 - - + + $("#" + displayId).scroll(function() { if (minimapScrolling) { minimapScrolling = false @@ -95,22 +145,31 @@ $(document).ready(function() { // Crea id per la div che contiene il canto $("#" + $(this).attr('name').replace(" ", "_")).attr('style', 'display:block') manageMiniMap(this); - + }); function manageMiniMap(divElem) { mmiw = $("#" + displayId).innerWidth(); 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(" ", "_")) } - + //Query jQuery(document).delegate('#searchcomm, #searchcomm2', 'click', function(e) { e.preventDefault(); manageQuery() }); - + //Reset @@ -121,47 +180,56 @@ $(document).ready(function() { $('#queryText').val("") }); - + //Utility functions - function getHoverContent(categ){ + function getHoverContent(categ) { //console.log('Categoria '+categ) - if(categ.includes('-')){ - categs=categ.split('-') - mycat=[] - for (cat of categs){ + if (categ.includes('-')) { + categs = categ.split('-') + mycat = [] + for (cat of categs) { mycat.push(cat[0]) } console.log(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() } - if(categ[0]=='s'){ + if (categ[0] == 's') { 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() } - if(categ[0]=='b'){ + if (categ[0] == 'b') { 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() } - if(categ[0]=='a'){ + if (categ[0] == 'a') { 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() } + 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]) return categoriegrammaticali[categ[0]] } - - function drawMinimap(name){ - + + function drawMinimap(name) { + showMinimap(name) currentMinimap = name; @@ -183,7 +251,7 @@ $(document).ready(function() { } }); } - + function cleanSearchResult() { for (verso of listarisultati) { @@ -195,25 +263,25 @@ $(document).ready(function() { if (currentMinimap != '') showMinimap(currentMinimap) } - - function manageQuery(){ + + function manageQuery() { cleanSearchResult() esprlogica = [] - jsonQuery=getJsonQuery() + jsonQuery = getJsonQuery() 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') return } jsonQuery = buildSQ(jsonQuery) - + myquery = new sparqlGenerator().stringify(jsonQuery) console.log(myquery) executeQuerySearch(myquery) } - + //minimap management - + function showMinimap(element) { mmplace = document.getElementById('displayminimap') @@ -257,21 +325,21 @@ $(document).ready(function() { - + function getInnerHeight(elm) { var computed = getComputedStyle(elm), padding = parseInt(computed.paddingTop) + parseInt(computed.paddingBottom); return elm.clientHeight - padding } - + function getDimensionsDiv() { var cantoplace = document.getElementById(displayId) var elementplace = document.getElementById(mappedElement) var bodyWidth = elementplace.clientWidth; var bodyRatio = elementplace.clientHeight / bodyWidth; - + let winRatio = getInnerHeight(cantoplace) / (cantoplace.clientWidth); //minimap.style.width='15%'; @@ -283,7 +351,7 @@ $(document).ready(function() { viewer.style.paddingTop = `${winRatio * 100}%`; minimapContent.style.transform = `scale(${realScale})`; minimapContent.style.width = `${(100 / realScale)}%`; - minimapContent.style.height = `${(100 / realScale)}%`; + minimapContent.style.height = `${(100 / realScale)}%`; //minimapContent.style.height=`100%`; minimapContent.style.float = 'right'; } @@ -311,7 +379,7 @@ $(document).ready(function() { currentMinimap = '' } - + //Cantica management functions function showCantica(cantica) { @@ -324,22 +392,22 @@ $(document).ready(function() { if (cantica == 'Purgatorio') containerForme = formeseconda const endlc = performance.now(); - console.log(`Load `+cantica+` time: ${endlc - start} ms`); + console.log(`Load ` + cantica + ` time: ${endlc - start} ms`); var elverso, formaItem for (var cmpItem of containerForme) { - + formaItem = cmpItem.split("_") - + //createDivVerso(cantica, num, canto, forma, catgram, pos) - if (! setVersi.has(cantica + "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1])){ - elverso=createDivVerso(cantica, formaItem[3], 'Canto_' + formaItem[1], formaItem[0], formaItem[4], formaItem[2]) - setVersi.add(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]) + setVersi.add(cantica + "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1]) } - else{ + else { //setVersi = createDivVersi(setVersi, cantica, formaItem[3], 'Canto_' + formaItem[1]) createSpanFormeNew(cantica, 'Canto_' + formaItem[1], formaItem[3], formaItem[0], formaItem[4], formaItem[2], elverso) } - + /* forma.numverso = formaItem[3]; forma.canto = 'Canto ' + formaItem[1]; @@ -369,21 +437,21 @@ $(document).ready(function() { } */ - + function createSpanFormeNew(cantica, canto, numverso, forma, catgramm, pos, elementoverso) { var spanoccorrenza = $('') //var pos = parseInt(pos) - spanoccorrenza.attr('id', cantica + "_" + canto+ "_" + numverso + "_" + pos) + spanoccorrenza.attr('id', cantica + "_" + canto + "_" + numverso + "_" + pos) spanoccorrenza.attr('data-cg', catgramm) //if (listarisultati.length > 0 && listarisultati.includes(spanoccorrenza.attr('id'))) // spanoccorrenza.attr('class', "font-weight-bold mark ") - spanoccorrenza.append(forma+" ") + spanoccorrenza.append(forma + " ") //elementoverso = $('#' + cantica + "_" + canto + "_" + numverso) spanoccorrenza.appendTo(elementoverso) //elementoverso.append(' ') } - + function createDivVersi(setVersi, cantica, num, canto) { if (setVersi.has(cantica + "_" + num + "_" + canto)) return setVersi @@ -403,54 +471,33 @@ $(document).ready(function() { } function createDivVerso(cantica, num, canto, forma, catgram, pos) { - - var elementoverso = $('

') - elementoverso.append(num + ". ") - elementoverso.attr("style", "line-height: 0.5em") + var elementoverso = $('

') - 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) - - var spanoccorrenza = $('') - //var pos = parseInt(pos) - spanoccorrenza.attr('id', cantica + "_" + canto+ "_" + num + "_" + pos) - spanoccorrenza.attr('data-cg', catgram) - - spanoccorrenza.append(forma+" ") - spanoccorrenza.appendTo(elementoverso) - - elementoverso.appendTo('#' + cantica + canto) - return elementoverso + elementoverso.attr('class', 'f6 text-secondary text-nowrap font-weight-lighter') + + elementoverso.attr('id', cantica + "_" + canto + "_" + num) + + var spanoccorrenza = $('') + //var pos = parseInt(pos) + spanoccorrenza.attr('id', cantica + "_" + canto + "_" + num + "_" + pos) + spanoccorrenza.attr('data-cg', catgram) + + spanoccorrenza.append(forma + " ") + spanoccorrenza.appendTo(elementoverso) + + elementoverso.appendTo('#' + cantica + canto) + return elementoverso } -/* - function createDivCanti(orderedListaCanti, cantica, canto) { - if (orderedListaCanti.has(canto)) { - return orderedListaCanti - } - var divcanto = $('

') - var titolocanto = $('

') - 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 + /* + function createDivCanti(orderedListaCanti, cantica, canto) { + if (orderedListaCanti.has(canto)) { + return orderedListaCanti + } var divcanto = $('
') var titolocanto = $('

') titolocanto.append(cantica + ", " + canto) @@ -459,13 +506,34 @@ $(document).ready(function() { 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 = $('
') + var titolocanto = $('

') + 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 - + async function executeQuerySearch(query) { $("#loader").show(); seachbBindingsStream = await myEngine.queryBindings(query, { sources: [{ type: 'sparql', value: sparqlEndpoint },], }); @@ -478,20 +546,20 @@ $(document).ready(function() { seachbBindingsStream.on('data', (binding) => { //cantica cantica = binding.get('Cantica').value; - + //canto canto = binding.get('Canto').value; - + //numero del verso numverso = binding.get('NumeroVerso').value; //posizione del frammento 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) resultsInCantica.push(cantica); resultsInCanto.push(cantica + canto) } - + }); seachbBindingsStream.on('end', () => { @@ -509,7 +577,7 @@ $(document).ready(function() { for (cantica of cantiche) { i += 1 let count = resultsInCantica.reduce((n, x) => n + (x === cantica), 0); - if (count>0){ + if (count > 0) { var spanbadgecantica = $(''); spanbadgecantica.attr('class', 'badge badge-primary badge-pill ml-1'); spanbadgecantica.append(count) @@ -523,7 +591,7 @@ $(document).ready(function() { if (k == 0) continue let count = resultsInCanto.reduce((n, x) => n + (x === cantica + 'Canto ' + k), 0); - if (count>0){ + if (count > 0) { var spanbadge = $(''); spanbadge.attr('class', cantobadgeclass); 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()} -Filtro= fhead:("v")? tail:( transitivita? diatesi? impersonalita? + var categoriegrammaticaliGrammar = `Expression = head:(Filtro){return 'Verbo,'+head.join()} +Filtro= fhead:("v") tail:( transitivita? diatesi? impersonalita* coniugazione? modotempo? - persona? funzione? declinazione? + persona? funzione* declinazione? genere? numero? grado?){return tail} - 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';} -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())){ case(1): return ' Prima coniugazione'; @@ -633,9 +700,9 @@ _ "whitespace"= " "* ` -var categoriaGrammaticaleSostantivo = ` + var categoriaGrammaticaleSostantivo = ` 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} @@ -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';} -locuzione="Iv" {return('In Locuzione verbo');} +locuzione="lv" {return('In Locuzione verbo');} Integer "integer" = _ [0-9]+ { return parseInt(text(), 10); } @@ -659,9 +726,9 @@ _ "whitespace"= " "* ` -var categoriaGrammaticalePreposizione = ` + var categoriaGrammaticalePreposizione = ` 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';} @@ -741,17 +808,16 @@ complemento2= "k14" {return(" Di Rapporto")} ` -var avverbio = ` Expression = head:(Filtro){return 'Avverbio,'+head.join()} -Filtro= fhead:("b")? tail:( fake? tipo?){return tail} - -fake= "" + var avverbio = `Expression = head:(Filtro){return 'Avverbio,'+head.join()} +Filtro= fhead:("b") tail:( locuzione? tipo?){return tail} + +locuzione = "lz" {return(' Avverbio in Locuzione Separato')}/ +"l" {return(' Avverbio in Locuzione')} tipo="c+" {return(' Avverbio al Comparativo di Maggioranza')}/ "c-" {return(' Avverbio al Comparativo di Minoranza')}/ "sa" {return(' Avverbio al Superlativo Assoluto')}/ "sr" {return(' Avverbio al Superlativo Relativo')}/ - "lz" {return(' Avverbio in Locuzione Separato')}/ - "l" {return(' Avverbio in Locuzione')}/ "y" {return(' Avverbio Proclitico')}/ "x" {return(' Avverbio Enclitico')}/ "c" {return(' Avverbio al Comparativo di Uguaglianza')} @@ -762,12 +828,11 @@ Integer "integer" _ "whitespace"= " "* + ` -var pronome = ` - -Expression = head:(Filtro){return 'Pronome,'+head.join()} -Filtro= fhead:("p")? tail:( tipo_pronome? classe_pronome? genere_pronome? + var 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} @@ -794,8 +859,8 @@ forma_pronome= "l" {return(" Pronome Libero")}/ "i" {return(" Pronome Libero In Composizione")}/ "y" {return(" Pronome Proclitico")}/ "x" {return(" Pronome Enclitico")} -funzione_pronome="so" {return(' Libero Soggetto')}/ - "soi" {return(' Libero Soggetto Impersonale')}/ +funzione_pronome= "soi" {return(' Libero Soggetto Impersonale')}/ + "so" {return(' Libero Soggetto')}/ "co" {return(' Libero Complemento')}/ "ra" {return(' Libero Rafforzativo')}/ "ac" {return(' Clitico Accusativo')}/ @@ -816,9 +881,9 @@ Integer "integer" _ "whitespace"= " "* ` -var categoriaGrammaticaleAggettivo = ` + var categoriaGrammaticaleAggettivo = ` 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? oggetto_indiretto?){return tail} @@ -899,10 +964,10 @@ Integer "integer" _ "whitespace"= " "* ` -var categoriaGrammaticaleArticolo = ` + var categoriaGrammaticaleArticolo = ` 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 = "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 -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); +fake = "" +tipo="l" {return(' Citazione Latina')}/ + "p" {return(' Citazione Provenzale')}/ + "r" {return(' Citazione Francese')}/ + "s" {return(' Citazione Spagnola')}/ + "e" {return(' Citazione Ebraica')}/ + "g" {return(' Citazione Greca')} + +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); });