gestione query con macrotipi sintattici

This commit is contained in:
cesare 2023-12-22 09:38:24 +01:00
parent 03b79ed91f
commit 86ad58b373
1 changed files with 103 additions and 7 deletions

View File

@ -573,10 +573,21 @@ function buildStatementClause(clause, parsedquery, whereind, theplace) {
tmpgroup.patterns.at(-1).triples.push(myf)
}
if (typeS != null && typeS != ".+") {
let mymt=macrotipi_sint[typeS]
if(listaMacroTipiConSubTipo.includes(mymt.split(':')[1])){
let myfa=buildMacroSyntType(mymt)
for (fa in myfa){
//tmpgroup.patterns.at(-1).triples.push(myfa[fa])
tmpgroup.patterns.push(myfa[fa])
}
}
else{
myf = buildsyntClause(macrotipi_sint[typeS])
if (myf != '')
tmpgroup.patterns.at(-1).triples.push(myf)
}
}
}
theplace.push(tmpgroup)
@ -620,8 +631,22 @@ function buildSintacticClause(clause, parsedquery, whereind) {
}
if (typeS != null && typeS != ".+") {
var alltipi = Object.assign(macrotipi_sint, tipi_sint);
let mymt=alltipi[typeS]
if(listaMacroTipiConSubTipo.includes(mymt.split(':')[1])){
let myfa=buildMacroSyntType(mymt)
for (fa in myfa){
//parsedquery.where.at(-1).triples.push(myfa[fa])
parsedquery.where.push(myfa[fa])
}
}
else{
myf = buildsyntClause(alltipi[typeS])
parsedquery.where.at(-1).triples.push(myf);
if (myf != '')
parsedquery.where.at(-1).triples.push(myf)
}
//myf = buildsyntClause(alltipi[typeS])
//parsedquery.where.at(-1).triples.push(myf);
}
return parsedquery
}
@ -887,14 +912,83 @@ function buildFilterStatement(target, filter, opzione) {
return (statement)
}
//"hasClauseType:Comparativa"
//
//?cl syntit:hasClauseType ?tipoSint .
//?tipoSint rdf:type syntit:ClauseSubType ;
// ecrm:P127_has_broader_term syntit:Comparativa .
function buildMacroSyntType(sttmnt){
var uniontmpms=`{"type": "union", "patterns":[]}`
var trm1=`{
"type": "bgp",
"triples":
[
{"subject": {"termType": "Variable","value": "cl"},
"predicate": {"termType": "NamedNode", "value": "https://dantenetwork.it/ontology/syntit/current/hasClauseType"},
"object": {"termType": "Variable","value": "tipoSint"}},
{"subject": {"termType": "Variable","value": "tipoSint"},
"predicate": {"termType": "NamedNode","value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"},
"object": {"termType": "NamedNode", "value": "https://dantenetwork.it/ontology/syntit/current/ClauseSubType"}},
{"subject": {"termType": "Variable","value": "tipoSint"},
"predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P127_has_broader_term"},
"object": {"termType": "NamedNode"}}
]
}`
var tmplate = `{"subject": {"termType": "Variable", "value":"cl"},
"predicate": {"termType":"NamedNode"},
"object": {"termType": "NamedNode"}}`
var t1m= `{"subject": {"termType": "Variable","value": "cl"},
"predicate": {"termType": "NamedNode", "value": "https://dantenetwork.it/ontology/syntit/current/hasClauseType"},
"object": {"termType": "Variable","value": "tipoSint"}}`
var t2m= `{"subject": {"termType": "Variable","value": "tipoSint"},
"predicate": {"termType": "NamedNode","value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"},
"object": {"termType": "NamedNode", "value": "https://dantenetwork.it/ontology/syntit/current/ClauseSubType"}}`
var t3m= `{"subject": {"termType": "Variable","value": "tipoSint"},
"predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P127_has_broader_term"},
"object": {"termType": "NamedNode"}}`
var res=[]
var obj = syntitprefix + (sttmnt.split(':')[1])
var predicate = syntitprefix + (sttmnt.split(':')[0])
var statement = JSON.parse(tmplate)
statement['predicate']['value'] = predicate
statement['object']['value'] = obj
var grstmt=JSON.parse(trm1)
grstmt['triples'][2]['object']['value']=obj
var unionst=JSON.parse(uniontmpms)
unionst['patterns'].push(grstmt)
unionst['patterns'].push(statement)
res.push(unionst)
//var statement = JSON.parse(t3m)
//statement['object']['value'] = obj
//res.push(JSON.parse(t1m))
//res.push(JSON.parse(t2m))
//res.push(statement)
return res
}
function buildsyntClause(sttmnt) {
var tmplate = `{"subject": {"termType": "Variable", "value":"cl"},
"predicate": {"termType":"NamedNode"},
"object": {"termType": "NamedNode"}}
`
console.log(sttmnt)
var predicate = syntitprefix + (sttmnt.split(':')[0])
var obj = syntitprefix + (sttmnt.split(':')[1])
var statement = JSON.parse(tmplate)
@ -1563,8 +1657,9 @@ var funzione_clausola =
"coord 0": "hasClauseFunction:PseudoCoordinateClause"
}
//da completare
var listaMacroTipiConSubTipo=['Concessiva', 'Comparativa', 'Ipotetica', 'Interrogativa', 'Iussiva', 'Ottativa']
var macrotipi_sint =
{
@ -1580,6 +1675,7 @@ var macrotipi_sint =
"macro esclu": "hasClauseType:Esclusiva",
"macro finale": "hasClauseType:Finale",
"macro inter princ": "hasClauseType:Interrogativa",
"macro inter sub": "hasClauseType:Interrogativa",
"macro ipotet": "hasClauseType:Ipotetica",
"macro iussi": "hasClauseType:Iussiva",
"macro limitat": "hasClauseType:Limitativa",