query sottocategorie verbale (in progress)
This commit is contained in:
parent
0d27fafedc
commit
73a54eb3bf
86
js/utils.js
86
js/utils.js
|
@ -96,13 +96,23 @@ function getStatements(){
|
|||
}
|
||||
|
||||
function buildSQ(stquery) {
|
||||
//const sparqlgen = sparqljs.Generator;
|
||||
//const generator = new sparqlgen({orl: "http://www.w3.org/2000/01/rdf-schema#" })
|
||||
//alert (stquery['EsprLogica'])
|
||||
var SparqlParser = sparqljs.Parser;
|
||||
var parser = new SparqlParser();
|
||||
const parsedquery =parser.parse(ontoSparqlQuery);
|
||||
const lf = document.getElementById("lemma_forma");
|
||||
const ftxt = document.getElementById("queryText");
|
||||
|
||||
|
||||
if (stquery['EsprLogica']!='' && stquery['EsprLogica'].length==1){
|
||||
clause=stquery['EsprLogica']
|
||||
|
||||
myquery=buildClause(stquery[clause], parsedquery)
|
||||
//const sparqlGenerator = sparqljs.Generator;
|
||||
//alert (new sparqlGenerator().stringify(myquery))
|
||||
return (myquery)
|
||||
}
|
||||
|
||||
if (ftxt.value.trim() != "") {
|
||||
|
||||
if (ftxt.value.trim().slice(-1) !=='*')
|
||||
|
@ -117,7 +127,9 @@ function buildSQ(stquery) {
|
|||
else{
|
||||
parsedquery.where.splice(1, 1)
|
||||
}
|
||||
|
||||
//categorie grammaticali
|
||||
/*
|
||||
mycg=document.getElementById("grammtypes1")
|
||||
if (mycg !=null && mycg.value != "all"){
|
||||
parsedquery.where[0].triples.push(JSON.parse(data21)[mycg.value]);
|
||||
|
@ -132,12 +144,74 @@ function buildSQ(stquery) {
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return (parsedquery)
|
||||
|
||||
}
|
||||
|
||||
function buildClause(clause, parsedquery){
|
||||
|
||||
if (clause['queryText'].trim() != "") {
|
||||
if (clause['queryText'].trim().slice(-1) !=='*')
|
||||
strval="^" +clause['queryText'].trim()+ "$";
|
||||
else
|
||||
strval=clause['queryText'].trim().slice(0, -1)
|
||||
|
||||
parsedquery.where[1].expression.args[1].value = strval;
|
||||
if (clause['lemma_forma'] == 'lemma')
|
||||
parsedquery.where[1].expression.args[0].value = "lm";
|
||||
}
|
||||
else{
|
||||
parsedquery.where.splice(1, 1)
|
||||
}
|
||||
if (clause['typeGramm0'] !=null && clause['typeGramm0'] != "all")
|
||||
parsedquery.where[0].triples.push(JSON.parse(data21)[clause['typeGramm0']]);
|
||||
|
||||
if (clause['typeGramm0'] !=null && clause['typeGramm0'].trim() == "verbovolgare"){
|
||||
sctmp=JSON.parse(sottoCategorieVerbi)
|
||||
sctk=Object.keys(sctmp)
|
||||
for (ke in sctk){
|
||||
//alert (clause[sctk[ke]])
|
||||
keval=clause[sctk[ke]]
|
||||
if (keval!=null && keval!=''){
|
||||
sttmts=sctmp[sctk[ke]]
|
||||
subcatstat= buildsubcategoryClause(sttmts[keval])
|
||||
parsedquery.where[0].triples.push(subcatstat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return parsedquery
|
||||
|
||||
|
||||
}
|
||||
|
||||
function buildsubcategoryClause(sttmnt){
|
||||
|
||||
subcattmplate=`{"subject": {"termType": "Variable", "value":"form"},
|
||||
"predicate": {"termType":"NamedNode"},
|
||||
"object": {"termType": "NamedNode"}}
|
||||
`
|
||||
|
||||
orlprefix='http://dantenetwork.it/ontology/ORL/'
|
||||
|
||||
|
||||
|
||||
predicate=orlprefix+(sttmnt.split(':')[0])
|
||||
obj=orlprefix+(sttmnt.split(':')[1])
|
||||
subcatstatement=JSON.parse(subcattmplate)
|
||||
|
||||
subcatstatement['predicate']['value']=predicate
|
||||
subcatstatement['object']['value']=obj
|
||||
|
||||
return (subcatstatement)
|
||||
|
||||
}
|
||||
|
||||
data21 = `{"verbovolgare": {"subject": {"termType": "Variable", "value":"form"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "object": {"termType": "NamedNode", "value": "http://dantenetwork.it/ontology/ORL/FormaVerboVolgare"}},
|
||||
"sostantivovolgare": {"subject": {"termType": "Variable", "value":"form"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "object": {"termType": "NamedNode", "value": "http://dantenetwork.it/ontology/ORL/FormaSostantivoVolgare"}},
|
||||
"aggettivovolgare": {"subject": {"termType": "Variable", "value":"form"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "object": {"termType": "NamedNode", "value": "http://dantenetwork.it/ontology/ORL/FormaAggettivoVolgare"}},
|
||||
|
@ -152,5 +226,11 @@ data21 = `{"verbovolgare": {"subject": {"termType": "Variable", "value":"form"},
|
|||
"locuzionevolgare": {"subject": {"termType": "Variable", "value":"form"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "object": {"termType": "NamedNode", "value": "http://dantenetwork.it/resource/ORL/FormaLocuzioneVolgare"}}
|
||||
}
|
||||
`
|
||||
|
||||
sottoCategorieVerbi=`{"Diatesi": {"Attivo": "TipoDiatesiVerboVolgare:VerboVolgareAttivo", "Passivo": "TipoDiatesiVerboVolgare:VerboVolgarePassivo"},
|
||||
"Transitivita": {"Intransitivo": "TipoTransitivitàVerboVolgare:VerboVolgareIntransitivo", "Transitivo": "TipoTransitivitàVerboVolgare:VerboVolgareTransitivo"},
|
||||
"Genere": {"Femminile": "TipoGenereVerboVolgare:GenereFemminileVerboVolgare", "Maschile": "TipoGenereVerboVolgare:GenereMaschileVerboVolgare"}}
|
||||
`
|
||||
|
||||
sottoCategorie=`{"verbovolgare": ["Diatesi,2", "Transitivita,2", "Genere,2", "Numero,2", "Pers,1", "Rifl,1", "Coniugazione,n", "Tempi,n", "Persona,n", "Funzione,n", "Declinazione,n"],
|
||||
"sostantivovolgare": ["pippo,2", "pluto,2"]}`
|
||||
|
|
Loading…
Reference in New Issue