implementazione query
This commit is contained in:
parent
d51c1db213
commit
bae04cb5ee
|
@ -192,7 +192,7 @@ const clausetarget_coalesce =
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
const clausepos_filter=`
|
const clausepos_gr_filter=`
|
||||||
{
|
{
|
||||||
"type": "filter",
|
"type": "filter",
|
||||||
"expression": {
|
"expression": {
|
||||||
|
@ -201,7 +201,7 @@ const clausepos_filter=`
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"type": "operation",
|
"type": "operation",
|
||||||
"operator": ">",
|
"operator": ">=",
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"termType": "Variable",
|
"termType": "Variable",
|
||||||
|
@ -215,7 +215,7 @@ const clausepos_filter=`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "operation",
|
"type": "operation",
|
||||||
"operator": "<",
|
"operator": "<=",
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"termType": "Variable",
|
"termType": "Variable",
|
||||||
|
@ -232,6 +232,46 @@ const clausepos_filter=`
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const clausepos_sy_filter=`
|
||||||
|
{
|
||||||
|
"type": "filter",
|
||||||
|
"expression": {
|
||||||
|
"type": "operation",
|
||||||
|
"operator": "&&",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"type": "operation",
|
||||||
|
"operator": "=",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"termType": "Variable",
|
||||||
|
"value": "clto"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"termType": "Variable",
|
||||||
|
"value": "clto_"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "operation",
|
||||||
|
"operator": "=",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"termType": "Variable",
|
||||||
|
"value": "clfr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"termType": "Variable",
|
||||||
|
"value": "clfr_"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
//Query per advanced search con obiettivo = 'Periodo'
|
//Query per advanced search con obiettivo = 'Periodo'
|
||||||
const sentencetargetquery = `
|
const sentencetargetquery = `
|
||||||
PREFIX ecrm: <http://erlangen-crm.org/current/>
|
PREFIX ecrm: <http://erlangen-crm.org/current/>
|
||||||
|
@ -341,21 +381,34 @@ const sentencetarget_posbind =
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|
||||||
const sentencetarget_syntgroup = `{
|
const sentencetarget_syntgroup = `{
|
||||||
"type": "group",
|
"type": "group",
|
||||||
"patterns": [
|
"patterns": [
|
||||||
{
|
{
|
||||||
"type": "bgp",
|
"type": "bgp",
|
||||||
"triples": [
|
"triples": [
|
||||||
{"subject": {"termType": "Variable","value": "sentence"},
|
{"subject": {"termType": "Variable","value": "sentence"},
|
||||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasSyntacticalComponent"},
|
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasSyntacticalComponent"},
|
||||||
"object": {"termType": "Variable","value": "cl"}},
|
"object": {"termType": "Variable","value": "cl"}},
|
||||||
{"subject": {"termType": "Variable","value": "cl"},
|
{"subject": {"termType": "Variable","value": "cl"},
|
||||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasClauseType"},
|
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasClauseType"},
|
||||||
"object": {"termType": "Variable","value": "clatype"}},
|
"object": {"termType": "Variable","value": "clatype"}},
|
||||||
{"subject": {"termType": "Variable","value": "cl"},
|
{"subject": {"termType": "Variable","value": "cl"},
|
||||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasClauseFunction"},
|
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasClauseFunction"},
|
||||||
"object": {"termType": "Variable","value": "clafunction"}}
|
"object": {"termType": "Variable","value": "clafunction"}},
|
||||||
|
{"subject": {"termType": "Variable","value": "claocc"},
|
||||||
|
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occurrenceOf"},
|
||||||
|
"object": {"termType": "Variable","value": "cl"}},
|
||||||
|
{"subject": {"termType": "Variable","value": "claocc"},
|
||||||
|
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occursInRegion"},
|
||||||
|
"object": {"termType": "Variable","value": "fragcl"}},
|
||||||
|
{"subject": {"termType": "Variable","value": "fragcl"},
|
||||||
|
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/fragmentRegionFrom"},
|
||||||
|
"object": {"termType": "Variable","value": "clfr"}},
|
||||||
|
{"subject": {"termType": "Variable","value": "fragcl"},
|
||||||
|
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/fragmentRegionTo"},
|
||||||
|
"object": {"termType": "Variable","value": "clto"}}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -363,6 +416,43 @@ const sentencetarget_syntgroup = `{
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const syntgroup_or_expr=`{
|
||||||
|
"type": "operation",
|
||||||
|
"operator": "&&",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"type": "operation",
|
||||||
|
"operator": "=",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"termType": "Variable",
|
||||||
|
"value": "clto"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"termType": "Variable",
|
||||||
|
"value": "clto_"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "operation",
|
||||||
|
"operator": "=",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"termType": "Variable",
|
||||||
|
"value": "clfr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"termType": "Variable",
|
||||||
|
"value": "clfr_"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
|
||||||
const sentencetarget_morphgroup = `{"type": "group",
|
const sentencetarget_morphgroup = `{"type": "group",
|
||||||
"patterns": [{"type": "bgp",
|
"patterns": [{"type": "bgp",
|
||||||
"triples": [
|
"triples": [
|
||||||
|
|
|
@ -379,7 +379,7 @@ var unionop = `{"union": {"type": "union", "patterns":[]}, "bgp": {"type": "bgp"
|
||||||
|
|
||||||
var idtoken = 0;
|
var idtoken = 0;
|
||||||
var idtokenor = 0;
|
var idtokenor = 0;
|
||||||
var orfilters=[]
|
var orfilters = []
|
||||||
function parseJsonClause(op, tokens, nowhere) {
|
function parseJsonClause(op, tokens, nowhere) {
|
||||||
//alert(op)
|
//alert(op)
|
||||||
var idp = -1
|
var idp = -1
|
||||||
|
@ -391,10 +391,10 @@ function parseJsonClause(op, tokens, nowhere) {
|
||||||
if (op.trim() == 'OR') {
|
if (op.trim() == 'OR') {
|
||||||
|
|
||||||
nowhere.splice(0, 0, JSON.parse(unionop)['union'])
|
nowhere.splice(0, 0, JSON.parse(unionop)['union'])
|
||||||
idtokenor=idtoken+20
|
idtokenor = idtoken + 20
|
||||||
var tmpcoal=clausetarget_coalesce.replaceAll("pos","pos"+idtokenor)
|
var tmpcoal = clausetarget_coalesce.replaceAll("pos", "pos" + idtokenor)
|
||||||
clausePosCoalesceStatement = JSON.parse(tmpcoal);
|
clausePosCoalesceStatement = JSON.parse(tmpcoal);
|
||||||
tmpcoal =`{
|
tmpcoal = `{
|
||||||
"termType": "Variable",
|
"termType": "Variable",
|
||||||
"value": "pos`+ idtokenor + `"
|
"value": "pos`+ idtokenor + `"
|
||||||
}`
|
}`
|
||||||
|
@ -457,8 +457,8 @@ function buildSPQuery(guiquery) {
|
||||||
//here get clauses
|
//here get clauses
|
||||||
var jsonclauses = JSON.parse(clauses)
|
var jsonclauses = JSON.parse(clauses)
|
||||||
idtoken = 0
|
idtoken = 0
|
||||||
idtokenor=0
|
idtokenor = 0
|
||||||
orfilters=[]
|
orfilters = []
|
||||||
for (const ck of Object.keys(jsonclauses)) {
|
for (const ck of Object.keys(jsonclauses)) {
|
||||||
parseJsonClause(ck, jsonclauses[ck], multipleCondSpQuery.where)
|
parseJsonClause(ck, jsonclauses[ck], multipleCondSpQuery.where)
|
||||||
|
|
||||||
|
@ -759,7 +759,7 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token, op
|
||||||
tmpg = tmpg.replaceAll('"lm"', '"lm' + token + '"')
|
tmpg = tmpg.replaceAll('"lm"', '"lm' + token + '"')
|
||||||
tmpg = tmpg.replaceAll('"reg"', '"reg' + token + '"')
|
tmpg = tmpg.replaceAll('"reg"', '"reg' + token + '"')
|
||||||
|
|
||||||
if (op=='OR')
|
if (op == 'OR')
|
||||||
tmpg = tmpg.replaceAll('"clg"', '"clg' + token + '"')
|
tmpg = tmpg.replaceAll('"clg"', '"clg' + token + '"')
|
||||||
else
|
else
|
||||||
tmpg = tmpg.replaceAll('"clg"', '"cl"')
|
tmpg = tmpg.replaceAll('"clg"', '"cl"')
|
||||||
|
@ -795,16 +795,27 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token, op
|
||||||
}`
|
}`
|
||||||
if (op == 'OR') {
|
if (op == 'OR') {
|
||||||
clausePosCoalesceStatement['expression']['args'].push(JSON.parse(tmppos))
|
clausePosCoalesceStatement['expression']['args'].push(JSON.parse(tmppos))
|
||||||
var orfilter=clausepos_filter.replaceAll("pos_", "pos"+idtokenor)
|
var orfilter = JSON.parse(clausepos_gr_filter.replaceAll("pos_", "pos" + idtokenor))
|
||||||
if (orfilters.length==0 || !orfilters.includes(orfilter)){
|
|
||||||
parsedquery['where'].push(JSON.parse(orfilter))
|
if (orfilters.length == 0 || !orfilters.includes(JSON.stringify(orfilter))) {
|
||||||
orfilters.push(orfilter)
|
if (parsedquery['where'].at(-1).type == "filter") {
|
||||||
|
var texp = JSON.parse(JSON.stringify(parsedquery['where'].at(-1).expression))
|
||||||
|
var targs = []
|
||||||
|
targs.push(texp)
|
||||||
|
targs.push(JSON.parse(JSON.stringify(orfilter.expression)))
|
||||||
|
parsedquery['where'].at(-1).expression.operator = '||'
|
||||||
|
parsedquery['where'].at(-1).expression.args = targs
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parsedquery['where'].push(orfilter)
|
||||||
|
}
|
||||||
|
orfilters.push(JSON.stringify(orfilter))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
parsedquery['variables'].push(JSON.parse(tmppos))
|
parsedquery['variables'].push(JSON.parse(tmppos))
|
||||||
var andfilter=clausepos_filter.replaceAll("pos_", "pos"+ token)
|
var andfilter = clausepos_gr_filter.replaceAll("pos_", "pos" + token)
|
||||||
parsedquery['where'].push(JSON.parse(andfilter))
|
parsedquery['where'].push(JSON.parse(andfilter))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,14 +873,37 @@ function buildStatementClause(clause, parsedquery, whereind, theplace, token, op
|
||||||
}
|
}
|
||||||
if (theguiQ['unitaRicerca'] == 'periodo' || theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {
|
if (theguiQ['unitaRicerca'] == 'periodo' || theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {
|
||||||
mytest = JSON.stringify(tmpgroup)
|
mytest = JSON.stringify(tmpgroup)
|
||||||
if (op=='OR')
|
|
||||||
mytest = tmpg.replaceAll(':"cl"', ':"cl' + token + '"')
|
|
||||||
mytest = mytest.replaceAll(':"clatype"', ':"clatype' + token + '"')
|
mytest = mytest.replaceAll(':"clatype"', ':"clatype' + token + '"')
|
||||||
mytest = mytest.replaceAll(':"clafunction"', ':"clafunction' + token + '"')
|
mytest = mytest.replaceAll(':"clafunction"', ':"clafunction' + token + '"')
|
||||||
mytest = mytest.replaceAll(':"cloccu"', ':"cloccu' + token + '"')
|
mytest = mytest.replaceAll(':"cloccu"', ':"cloccu' + token + '"')
|
||||||
|
mytest = mytest.replaceAll(':"clocc"', ':"clocc' + token + '"')
|
||||||
|
mytest = mytest.replaceAll(':"fragcl"', ':"fragcl' + token + '"')
|
||||||
|
mytest = mytest.replaceAll(':"clfr"', ':"clfr' + token + '"')
|
||||||
|
mytest = mytest.replaceAll(':"clto"', ':"clto' + token + '"')
|
||||||
mytest = mytest.replaceAll(':"fa"', ':"fa' + token + '"')
|
mytest = mytest.replaceAll(':"fa"', ':"fa' + token + '"')
|
||||||
mytest = mytest.replaceAll(':"form"', ':"form' + token + '"')
|
mytest = mytest.replaceAll(':"form"', ':"form' + token + '"')
|
||||||
mytest = mytest.replaceAll(':"Rappresentazione"', ':"Rappresentazione' + token + '"')
|
mytest = mytest.replaceAll(':"Rappresentazione"', ':"Rappresentazione' + token + '"')
|
||||||
|
if (op == 'OR') {
|
||||||
|
mytest = mytest.replaceAll(':"cl"', ':"cl' + token + '"')
|
||||||
|
var syore = JSON.parse(clausepos_sy_filter.replaceAll(': "clfr_"', ': "clfr' + token + '"').replaceAll(': "clto_"', ': "clto' + token + '"'))
|
||||||
|
|
||||||
|
if (orfilters.length == 0 || !orfilters.includes(JSON.stringify(syore))) {
|
||||||
|
if (parsedquery['where'].at(-1).type == "filter") {
|
||||||
|
var texp = JSON.parse(JSON.stringify(parsedquery['where'].at(-1).expression))
|
||||||
|
var targs = []
|
||||||
|
targs.push(texp)
|
||||||
|
targs.push(JSON.parse(JSON.stringify(syore.expression)))
|
||||||
|
parsedquery['where'].at(-1).expression.operator = '||'
|
||||||
|
parsedquery['where'].at(-1).expression.args = targs
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parsedquery['where'].push(syore)
|
||||||
|
}
|
||||||
|
orfilters.push(JSON.stringify(syore))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var mystrb = `{
|
var mystrb = `{
|
||||||
"type": "operation",
|
"type": "operation",
|
||||||
"operator": "str",
|
"operator": "str",
|
||||||
|
@ -946,7 +980,7 @@ function buildSintacticClause(clause, parsedquery, whereind) {
|
||||||
var functS = clause['functionSyntax'];
|
var functS = clause['functionSyntax'];
|
||||||
var typeS = clause['typeSyntax0']
|
var typeS = clause['typeSyntax0']
|
||||||
console.log(functS + ' ' + typeS)
|
console.log(functS + ' ' + typeS)
|
||||||
if (functS != null && functS != ".+") {
|
if (functS != null && functS != "all") {
|
||||||
//console.log('functS '+funzione_clausola['princ'])
|
//console.log('functS '+funzione_clausola['princ'])
|
||||||
var myf = buildsyntClause(funzione_clausola[functS])
|
var myf = buildsyntClause(funzione_clausola[functS])
|
||||||
|
|
||||||
|
@ -954,7 +988,7 @@ function buildSintacticClause(clause, parsedquery, whereind) {
|
||||||
return parsedquery
|
return parsedquery
|
||||||
parsedquery.where.at(-1).triples.push(myf);
|
parsedquery.where.at(-1).triples.push(myf);
|
||||||
}
|
}
|
||||||
if (typeS != null && typeS != ".+") {
|
if (typeS != null && typeS != "all") {
|
||||||
var alltipi = Object.assign(macrotipi_sint, tipi_sint);
|
var alltipi = Object.assign(macrotipi_sint, tipi_sint);
|
||||||
let mymt = alltipi[typeS]
|
let mymt = alltipi[typeS]
|
||||||
if (listaMacroTipiConSubTipo.includes(mymt.split(':')[1])) {
|
if (listaMacroTipiConSubTipo.includes(mymt.split(':')[1])) {
|
||||||
|
|
Loading…
Reference in New Issue