implementazione query, in progress
This commit is contained in:
parent
157ac5c5a2
commit
eacd2b48e4
|
@ -109,6 +109,88 @@ WHERE {
|
|||
}`
|
||||
|
||||
|
||||
//Query per advanced search con obiettivo = 'Frase'
|
||||
const clausetargetquery = `
|
||||
PREFIX ecrm: <http://erlangen-crm.org/current/>
|
||||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
||||
PREFIX olires: <https://dantenetwork.it/ontology/olires/current/>
|
||||
PREFIX syntit: <https://dantenetwork.it/ontology/syntit/current/>
|
||||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||
PREFIX lemon: <http://lemon-model.net/lemon#>
|
||||
PREFIX orl: <https://dantenetwork.it/ontology/orl/current/>
|
||||
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
|
||||
|
||||
SELECT distinct (?t_canto AS ?Canto) (?t_cantica AS ?Cantica) ?sentence ?clfr ?clto ?clafunction ?clt ?pos WHERE {
|
||||
{
|
||||
?sentence rdf:type syntit:Sentence;
|
||||
syntit:hasSyntacticalComponent ?cl;
|
||||
ecrm:P148i_is_component_of ?canto.
|
||||
?cl syntit:hasClauseType ?clatype;
|
||||
syntit:hasClauseFunction ?clafun.
|
||||
?seocc olires:occurrenceOf ?sentence;
|
||||
olires:occursInRegion ?frag.
|
||||
?claocc olires:occurrenceOf ?cl;
|
||||
olires:occursInRegion ?fragcl.
|
||||
?fragcl olires:fragmentRegionFrom ?clfr;
|
||||
olires:fragmentRegionTo ?clto.
|
||||
}
|
||||
?canto ecrm:P102_has_title ?t_canto;
|
||||
olires:hasNumber ?num.
|
||||
?cantica ecrm:P102_has_title ?t_cantica;
|
||||
olires:hasStructuralComponent ?canto.
|
||||
BIND(CONCAT(STR(?clafun), ';') AS ?clafunction)
|
||||
BIND(STR(?clatype) AS ?clt)
|
||||
FILTER (?clto > ?pos && ?clfr<?pos) .
|
||||
}`
|
||||
|
||||
//bindConcatStatement
|
||||
const clausetarget_functionbind=
|
||||
`{
|
||||
"type": "bind",
|
||||
"variable": {
|
||||
"termType": "Variable",
|
||||
"value": "clafun"
|
||||
},
|
||||
"expression": {
|
||||
"type": "operation",
|
||||
"operator": "concat",
|
||||
"args": []
|
||||
}
|
||||
}`
|
||||
//clauseTypeBindConcatStatement
|
||||
const clausetarget_typebind=
|
||||
`{
|
||||
"type": "bind",
|
||||
"variable": {
|
||||
"termType": "Variable",
|
||||
"value": "clatype"
|
||||
},
|
||||
"expression": {
|
||||
"type": "operation",
|
||||
"operator": "concat",
|
||||
"args": []
|
||||
}
|
||||
}`
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
//clausePosCoalesceStatement
|
||||
const clausetarget_coalesce=
|
||||
`{
|
||||
"type": "bind",
|
||||
"variable": {
|
||||
"termType": "Variable",
|
||||
"value": "pos"
|
||||
},
|
||||
"expression": {
|
||||
"type": "operation",
|
||||
"operator": "coalesce",
|
||||
"args": []
|
||||
}
|
||||
}`
|
||||
|
||||
//Query per advanced search con obiettivo = 'Periodo'
|
||||
const sentencetargetquery = `
|
||||
|
@ -170,6 +252,7 @@ const sentencetargetstatement_posCoalesce=JSON.parse(`{
|
|||
}
|
||||
}`)
|
||||
|
||||
|
||||
const sentencetarget_functionbind=
|
||||
`
|
||||
{
|
||||
|
|
|
@ -367,6 +367,8 @@ function getStatements() {
|
|||
var theguiQ = ''
|
||||
var multipleCondSpQuery = ''
|
||||
var bindConcatStatement = ''
|
||||
var clauseTypeBindConcatStatement=''
|
||||
var clausePosCoalesceStatement=''
|
||||
var occBindConcatStatement = ''
|
||||
var posBindConcatStatement = ''
|
||||
|
||||
|
@ -387,7 +389,6 @@ function parseJsonClause(op, tokens, nowhere) {
|
|||
|
||||
//nowhere.splice(1, 0, JSON.parse(unionop)['union'])
|
||||
nowhere.splice(0, 0, JSON.parse(unionop)['union'])
|
||||
//idp = 1
|
||||
idp = 0
|
||||
}
|
||||
if (op.trim() == 'AND') {
|
||||
|
@ -420,15 +421,22 @@ function buildSPQuery(guiquery) {
|
|||
theguiQ = guiquery;
|
||||
var SparqlParser = sparqljs.Parser;
|
||||
var spqparser = new SparqlParser();
|
||||
if (theguiQ['unitaRicerca'] == 'periodo' || theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {//Multiple Conditions
|
||||
multipleCondSpQuery = spqparser.parse(ontoSparqlQueryMultCond);
|
||||
|
||||
if (theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {
|
||||
multipleCondSpQuery = spqparser.parse(clausetargetquery);
|
||||
clausePosCoalesceStatement = JSON.parse(clausetarget_coalesce);
|
||||
|
||||
}
|
||||
if (theguiQ['unitaRicerca'] == 'periodo') {//Multiple Conditions
|
||||
multipleCondSpQuery = spqparser.parse(sentencetargetquery);
|
||||
bindConcatStatement = JSON.parse(sentencetarget_functionbind);
|
||||
occBindConcatStatement = JSON.parse(sentencetarget_occbind);
|
||||
posBindConcatStatement = JSON.parse(sentencetarget_posbind);
|
||||
|
||||
}
|
||||
else
|
||||
multipleCondSpQuery = spqparser.parse(ontoSparqlQueryMultCond);
|
||||
|
||||
|
||||
var parser = peg.generate(hdnquerygrammar);
|
||||
var test = guiquery['EsprLogica'].join(" ");
|
||||
test = test.replaceAll("( ", "(")
|
||||
|
@ -441,7 +449,17 @@ function buildSPQuery(guiquery) {
|
|||
parseJsonClause(ck, jsonclauses[ck], multipleCondSpQuery.where)
|
||||
|
||||
}
|
||||
if (theguiQ['unitaRicerca'] == 'periodo' || theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {
|
||||
if (theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {
|
||||
|
||||
multipleCondSpQuery.where.push(clausePosCoalesceStatement)
|
||||
/*if (posBindConcatStatement['expression']['args'].length) {
|
||||
multipleCondSpQuery.where.push(posBindConcatStatement)
|
||||
multipleCondSpQuery.variables.push(JSON.parse(sentencetarget_posVariable))
|
||||
//multipleCondSpQuery.where.push(sentencetargetstatement_posCoalesce)
|
||||
}*/
|
||||
|
||||
}
|
||||
if (theguiQ['unitaRicerca'] == 'periodo') {
|
||||
multipleCondSpQuery.where.push(bindConcatStatement)
|
||||
multipleCondSpQuery.where.push(occBindConcatStatement)
|
||||
|
||||
|
@ -735,7 +753,6 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token) {
|
|||
tmpg = tmpg.replaceAll('"reg"', '"reg' + token + '"')
|
||||
tmpg = tmpg.replaceAll('"clg"', '"clg' + token + '"')
|
||||
tmpg = tmpg.replaceAll('"cloccte"', '"cloccte' + token + '"')
|
||||
tmpgroup = JSON.parse(tmpg)
|
||||
var tmppos = `{
|
||||
"type": "operation",
|
||||
"operator": "str",
|
||||
|
@ -745,19 +762,29 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token) {
|
|||
"value": "pos`+ token + `"
|
||||
}
|
||||
]
|
||||
}
|
||||
`
|
||||
posBindConcatStatement['expression']['args'].push(JSON.parse(tmppos))
|
||||
tmppos = `{
|
||||
"termType": "Literal",
|
||||
"value": ";",
|
||||
"language": "",
|
||||
"datatype": {
|
||||
"termType": "NamedNode",
|
||||
"value": "http://www.w3.org/2001/XMLSchema#string"
|
||||
}
|
||||
}`
|
||||
posBindConcatStatement['expression']['args'].push(JSON.parse(tmppos))
|
||||
if (theguiQ['unitaRicerca'] == 'periodo'){
|
||||
posBindConcatStatement['expression']['args'].push(JSON.parse(tmppos))
|
||||
tmppos = `{"termType": "Literal",
|
||||
"value": ";",
|
||||
"language": "",
|
||||
"datatype": {
|
||||
"termType": "NamedNode",
|
||||
"value": "http://www.w3.org/2001/XMLSchema#string"
|
||||
}
|
||||
}`
|
||||
posBindConcatStatement['expression']['args'].push(JSON.parse(tmppos))
|
||||
}
|
||||
else
|
||||
{
|
||||
tmppos=`{
|
||||
"termType": "Variable",
|
||||
"value": "pos`+ token + `"
|
||||
}`
|
||||
clausePosCoalesceStatement['expression']['args'].push(JSON.parse(tmppos))
|
||||
}
|
||||
|
||||
tmpgroup = JSON.parse(tmpg)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1291,139 +1318,8 @@ function buildsubcategoryClause(sttmnt) {
|
|||
}
|
||||
//GESTIONE CITAZIONI/COMMENTI
|
||||
//return JSON object
|
||||
/*function getVersiConCitazioniJson(canticapar = '', cantopar = '') {
|
||||
let citcantiche = ['Inferno', 'Purgatorio', 'Paradiso']
|
||||
if (canticapar == '') {
|
||||
citazioni.map(function(item) {
|
||||
console.log(item['Cantica'] + ', ' + item['Canto'] + ', ' + item['Verso'].split('-')[0]);
|
||||
})
|
||||
return
|
||||
}
|
||||
var citazionitemp = {}
|
||||
citazioni.map(function(item) {
|
||||
if (item['Cantica'] == canticapar && item['Canto'] == cantopar) {
|
||||
|
||||
let tca = item['Canto']
|
||||
if (tca.startsWith('0'))
|
||||
tca = tca.replace('0', '')
|
||||
let citid = (citcantiche.indexOf(item['Cantica']) + 1).toString() + '_' + tca + '_' + item['Verso']//.split('-')[0]
|
||||
//console.log(citid)
|
||||
var commentsItem = {}
|
||||
commentsItem['verso'] = citid;
|
||||
commentsItem['annotazione'] = item['Ann'];
|
||||
commentsItem['commentario'] = item['Com'];
|
||||
commentsItem['frammentoNota'] = item['FrN'];
|
||||
commentsItem['AutoreCitazione'] = item['AC'];
|
||||
commentsItem['FonteCitazione'] = item['F'];
|
||||
commentsItem['LuogoFonteCitazione'] = item['LF'];
|
||||
commentsItem['NotaFonteCitazione'] = item['NF'];
|
||||
commentsItem['TestoFonteCitazione'] = item['TF'];
|
||||
commentsItem['URLFonteCitazione'] = item['UF'];
|
||||
commentsItem['NaturaRiferimento'] = item['NaRi'];
|
||||
commentsItem['RapportoCommentoCommentatoreText'] = item['RCC'];
|
||||
commentsItem['RapportoSoggettoOggetto'] = item['RSO'];
|
||||
commentsItem['NomeAutoreCitazione'] = item['Aut'];
|
||||
commentsItem['TitoloFonteCitazione'] = item['TiFo'];
|
||||
commentsItem['VersoCitazione'] = item['Verso'];
|
||||
|
||||
if (item['AC'] == '') {
|
||||
commentsItem['AutoreCitazione'] = 'autore'
|
||||
}
|
||||
|
||||
if (item['TiCi'] == 'no') {
|
||||
commentsItem['TipoCitazione'] = ''
|
||||
}
|
||||
else {
|
||||
commentsItem['TipoCitazione'] = item['TiCi']
|
||||
}
|
||||
//'CEP', 'CIM', 'CTE', 'CMO', 'CST', 'CTO'
|
||||
|
||||
if (item['CEP'] == 'no') {
|
||||
commentsItem['CitEpisodi'] = ''
|
||||
}
|
||||
else {
|
||||
commentsItem['CitEpisodi'] = item['CEP']
|
||||
}
|
||||
|
||||
if (item['CIM'] == 'no') {
|
||||
commentsItem['CitImmagini'] = ''
|
||||
}
|
||||
else {
|
||||
commentsItem['CitImmagini'] = item['CIM']
|
||||
}
|
||||
|
||||
if (item['CTE'] == 'no') {
|
||||
commentsItem['CitTeorie'] = ''
|
||||
}
|
||||
else {
|
||||
commentsItem['CitTeorie'] = item['CTE']
|
||||
}
|
||||
|
||||
if (item['CMO'] == 'no') {
|
||||
commentsItem['CitMotivi'] = ''
|
||||
}
|
||||
else {
|
||||
commentsItem['CitMotivi'] = item['CMO']
|
||||
}
|
||||
|
||||
if (item['CST'] == 'no') {
|
||||
commentsItem['CitStilemi'] = ''
|
||||
}
|
||||
else {
|
||||
commentsItem['CitStilemi'] = item['CST']
|
||||
}
|
||||
|
||||
if (item['CTO'] == 'no') {
|
||||
commentsItem['CitTopografie'] = ''
|
||||
}
|
||||
else {
|
||||
commentsItem['CitTopografie'] = item['CTO']
|
||||
}
|
||||
|
||||
if (citazionitemp.hasOwnProperty(citid)) {
|
||||
citazionitemp[citid].push(commentsItem)
|
||||
}
|
||||
else {
|
||||
var tmpar = []
|
||||
tmpar.push(commentsItem)
|
||||
citazionitemp[citid] = tmpar
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
console.log(citazionitemp)
|
||||
return citazionitemp;
|
||||
}
|
||||
|
||||
//inizializzazione UI per query sulle citazioni
|
||||
function getAutoriFontiCitazioni() {
|
||||
var listaAutori = new Set()
|
||||
citazioni.map(function(item) {
|
||||
listaAutori.add(item['Aut']);
|
||||
|
||||
if (item['Aut'] == '') {
|
||||
listaAutori.add('Sconosciuto')
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
return Array.from(listaAutori)
|
||||
}
|
||||
|
||||
function getCommentatori() {
|
||||
var listaCommentatori = new Set()
|
||||
citazioni.map(function(item) {
|
||||
listaCommentatori.add(item['Com']);
|
||||
|
||||
if (item['Com'] == '') {
|
||||
listaCommentatori.add('Sconosciuto')
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
return Array.from(listaCommentatori)
|
||||
}
|
||||
*/
|
||||
const myiframe = document.getElementsByClassName("minimap__content");
|
||||
function resetGraphStruct() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue