queries con target periodo in pogress
This commit is contained in:
parent
8a72fa2c01
commit
5f09f56448
165
js/utilsMgr.js
165
js/utilsMgr.js
|
@ -30,108 +30,6 @@ _ "whitespace"= " "*
|
|||
|
||||
var testmm = 0
|
||||
|
||||
//query per le ricerche
|
||||
|
||||
var ontoSparqlQuery = `PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||
PREFIX ecrm: <http://erlangen-crm.org/current/>
|
||||
PREFIX hdn: <http://dantenetwork.it/data/commedia/>
|
||||
PREFIX lemon: <http://lemon-model.net/lemon#>
|
||||
PREFIX orl: <https://dantenetwork.it/ontology/orl/current/>
|
||||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
||||
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
|
||||
PREFIX olires:<https://dantenetwork.it/ontology/olires/current/>
|
||||
PREFIX comm: <http://dantenetwork.it/data/commedia/>
|
||||
PREFIX syntit: <https://dantenetwork.it/ontology/syntit/current/>
|
||||
|
||||
SELECT (?t_canto as ?Canto) (?t_cantica as ?Cantica) ?clatype ?clafunction ?clfr ?clto ?cl ?sentence ?cltext ?pos ?clocc
|
||||
WHERE {
|
||||
FILTER(REGEX(?Rappresentazione, "^buon$", "i")) .
|
||||
FILTER(LANGMATCHES(LANG(?Rappresentazione), "it"))
|
||||
###condizioni grammaticali
|
||||
{
|
||||
|
||||
?form ontolex:writtenRep ?Rappresentazione.
|
||||
?lent ontolex:lexicalForm ?form;
|
||||
ontolex:canonicalForm ?cf.
|
||||
?cf ontolex:writtenRep ?lm.
|
||||
?fa olires:occurrenceOf ?form;
|
||||
olires:OccursInRegion ?reg .
|
||||
?reg olires:fragmentRegionFrom ?pos .
|
||||
}
|
||||
###end
|
||||
###condizioni sintattiche
|
||||
{
|
||||
?clocc olires:occurrenceOf ?cl ;
|
||||
ecrm:P148_has_component ?fa ; #condizione join grammaticale sintattica
|
||||
olires:occursInRegion ?frag .
|
||||
|
||||
?sentence a syntit:Sentence ;
|
||||
ecrm:P148i_is_component_of ?canto;
|
||||
syntit:hasSyntacticalComponent ?cl.
|
||||
|
||||
?cl syntit:hasClauseType ?clatype ;
|
||||
ecrm:P190_has_symbolic_content ?cltext ;
|
||||
syntit:hasClauseFunction ?clafunction.
|
||||
|
||||
?frag olires:fragmentRegionFrom ?clfr ;
|
||||
olires:fragmentRegionTo ?clto .
|
||||
}
|
||||
### end
|
||||
### condizioni comuni
|
||||
|
||||
?canto ecrm:P102_has_title ?t_canto;
|
||||
olires:hasNumber ?num .
|
||||
?cantica ecrm:P102_has_title ?t_cantica;
|
||||
olires:hasStructuralComponent ?canto.
|
||||
# FILTER (?t_cantica in ("Inferno", "Purgatorio"))
|
||||
# FILTER (?num IN ("12"^^xsd:short, "4"^^xsd:short ) )
|
||||
### end
|
||||
}`
|
||||
|
||||
var ontoSparqlQueryMultCond = `PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||
PREFIX ecrm: <http://erlangen-crm.org/current/>
|
||||
PREFIX hdn: <http://dantenetwork.it/data/commedia/>
|
||||
PREFIX lemon: <http://lemon-model.net/lemon#>
|
||||
PREFIX orl: <https://dantenetwork.it/ontology/orl/current/>
|
||||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
||||
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
|
||||
PREFIX olires:<https://dantenetwork.it/ontology/olires/current/>
|
||||
PREFIX comm: <http://dantenetwork.it/data/commedia/>
|
||||
PREFIX syntit: <https://dantenetwork.it/ontology/syntit/current/>
|
||||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||
|
||||
SELECT (?t_canto as ?Canto) (?t_cantica as ?Cantica) ?clatype ?clafunction ?clfr ?clto ?cl ?sentence ?pos ?clocc
|
||||
WHERE {
|
||||
FILTER(REGEX(?Rappresentazione, "^buon$", "i")) .
|
||||
FILTER(LANGMATCHES(LANG(?Rappresentazione), "it"))
|
||||
|
||||
### condizioni
|
||||
?canto ecrm:P102_has_title ?t_canto;
|
||||
olires:hasNumber ?num .
|
||||
?cantica ecrm:P102_has_title ?t_cantica;
|
||||
olires:hasStructuralComponent ?canto.
|
||||
###condizioni end
|
||||
###condizioni sintattiche
|
||||
{
|
||||
?clocc olires:occurrenceOf ?cl ;
|
||||
ecrm:P148_has_component ?fa ; # join grammaticale sintattica
|
||||
olires:occursInRegion ?frag .
|
||||
|
||||
?sentence a syntit:Sentence ;
|
||||
ecrm:P148i_is_component_of ?canto;
|
||||
syntit:hasSyntacticalComponent ?cl.
|
||||
|
||||
?cl syntit:hasClauseType ?clatype ;
|
||||
ecrm:P190_has_symbolic_content ?cltext ;
|
||||
syntit:hasClauseFunction ?clafunction.
|
||||
|
||||
?frag olires:fragmentRegionFrom ?clfr ;
|
||||
olires:fragmentRegionTo ?clto .
|
||||
#?frag olires:fragmentRegionFrom ?pos.
|
||||
}
|
||||
###condizioni sintattiche end
|
||||
BIND(COALESCE(?pos1,-1) AS ?pos)
|
||||
}`
|
||||
|
||||
|
||||
var ontoSparqlQuerySynt = `
|
||||
|
@ -336,6 +234,8 @@ var theguiQ = ''
|
|||
var multipleCondSpQuery = ''
|
||||
var bindConcatStatement=''
|
||||
var occBindConcatStatement=''
|
||||
var posBindConcatStatement=''
|
||||
|
||||
var conditions = []
|
||||
var filters = []
|
||||
var unionop = `{"union": {"type": "union", "patterns":[]}, "bgp": {"type": "bgp", "triples":[]}, "group": {"type": "group", "patterns":[]}}`
|
||||
|
@ -368,7 +268,7 @@ function parseJsonClause(op, tokens, nowhere) {
|
|||
te_op = tokens[mtoken]
|
||||
if ('TERM' in te_op) {
|
||||
cond = theguiQ[te_op['TERM']]
|
||||
//mywhere=nowhere[idp].patterns;
|
||||
|
||||
multipleCondSpQuery = buildStatementClause(cond, multipleCondSpQuery, -1, nowhere[idp].patterns, mtoken)
|
||||
|
||||
}
|
||||
|
@ -390,6 +290,7 @@ function buildSPQuery(guiquery) {
|
|||
multipleCondSpQuery = spqparser.parse(sentencetargetquery);
|
||||
bindConcatStatement=JSON.parse(sentencetarget_functionbind);
|
||||
occBindConcatStatement=JSON.parse(sentencetarget_occbind);
|
||||
posBindConcatStatement=JSON.parse(sentencetarget_posbind);
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -408,6 +309,11 @@ function buildSPQuery(guiquery) {
|
|||
if (theguiQ['unitaRicerca']=='periodo') {
|
||||
multipleCondSpQuery.where.push(bindConcatStatement)
|
||||
multipleCondSpQuery.where.push(occBindConcatStatement)
|
||||
if (posBindConcatStatement['expression']['args'].length){
|
||||
multipleCondSpQuery.where.push(posBindConcatStatement)
|
||||
//multipleCondSpQuery.where.push(sentencetargetstatement_posCoalesce)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -548,13 +454,22 @@ function getFiltroContestoJson(datiContesto) {
|
|||
|
||||
function buildStatementClause(clause, parsedquery, whereind, theplace, token) {
|
||||
//
|
||||
var tmpgroup=''
|
||||
if (clause['TipoClausola'] == "Sintattico") {
|
||||
if (theguiQ['unitaRicerca']=='periodo')
|
||||
tmpgroup=JSON.parse(sentencetarget_syntgroup)
|
||||
else
|
||||
tmpgroup = JSON.parse(syntgroup)
|
||||
}
|
||||
else tmpgroup = JSON.parse(morphgroup);
|
||||
if (clause['TipoClausola'] == "Grammaticale") {
|
||||
if (theguiQ['unitaRicerca']=='periodo'){
|
||||
tmpgroup=JSON.parse(sentencetarget_morphgroup_short)
|
||||
}
|
||||
|
||||
else
|
||||
tmpgroup = JSON.parse(morphgroup)
|
||||
}
|
||||
|
||||
|
||||
if (clause['queryText'] != null && clause['queryText'].trim() != "") {
|
||||
//theplace.push(JSON.parse(unionop)['group']);
|
||||
|
@ -593,6 +508,48 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (clause['TipoClausola']=='Grammaticale'){
|
||||
if (theguiQ['unitaRicerca']=='periodo'){
|
||||
var tmpg=JSON.stringify(tmpgroup)
|
||||
tmpg=tmpg.replaceAll('"Rappresentazione"', '"Rappresentazione'+token+'"')
|
||||
tmpg=tmpg.replaceAll('"form"', '"form'+token+'"')
|
||||
tmpg=tmpg.replaceAll('"lent"', '"lent'+token+'"')
|
||||
tmpg=tmpg.replaceAll('"cf"', '"cf'+token+'"')
|
||||
tmpg=tmpg.replaceAll('"fa"', '"fa'+token+'"')
|
||||
tmpg=tmpg.replaceAll('"pos"', '"pos'+token+'"')
|
||||
tmpg=tmpg.replaceAll('"lm"', '"lm'+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",
|
||||
"args": [
|
||||
{
|
||||
"termType": "Variable",
|
||||
"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))
|
||||
}
|
||||
}
|
||||
|
||||
// CLAUSOLA SINTATTICA
|
||||
|
||||
if (clause['TipoClausola'] == "Sintattico") {
|
||||
tmpgroup.patterns.push(JSON.parse(unionop)['bgp']);
|
||||
var functS = clause['functionSyntax'];
|
||||
|
|
Loading…
Reference in New Issue