visualizzazione risultati come frasi/periodi, tooltip, query con cond
sint e gramm
This commit is contained in:
parent
9dfe860b8a
commit
24343fea7d
|
@ -22,13 +22,17 @@
|
|||
* Footer
|
||||
*/
|
||||
|
||||
|
||||
#displaycanto span:hover {
|
||||
color: red;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Popover properties
|
||||
*/
|
||||
|
||||
/*
|
||||
.popover-header {
|
||||
color: blue;
|
||||
font-size: 13px;
|
||||
|
@ -41,6 +45,7 @@ Popover properties
|
|||
color: gray;
|
||||
font-size: 10px;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
Minimap
|
||||
|
@ -105,21 +110,26 @@ Minimap
|
|||
display: inline-block;
|
||||
}
|
||||
|
||||
|
||||
.Nik_dropdown-content {
|
||||
display: none;
|
||||
position: absolute;
|
||||
/*display: none;*/
|
||||
/*position: absolute;
|
||||
top: -60px;
|
||||
left: 50px;
|
||||
background-color: rgb(252, 252, 252);
|
||||
min-width: 270px;
|
||||
background-color: rgb(252, 252, 252);*/
|
||||
background-color: #92a8d1;
|
||||
max-width: 170px;
|
||||
/*min-width: 70px;
|
||||
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
||||
padding: 8px 8px;
|
||||
color:red;
|
||||
font-size: 10;
|
||||
padding: 8px 8px;*/
|
||||
color:blue;
|
||||
font-size: 10px;
|
||||
z-index: 1;
|
||||
float: top;
|
||||
/*float: top;*/
|
||||
}
|
||||
|
||||
.Nik_dropdown:hover .Nik_dropdown-content {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css">
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
|
||||
<!-- <link rel="stylesheet" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css"> -->
|
||||
<!-- <link rel="stylesheet" href="https://unpkg.com/tachyons/css/tachyons.min.css"> -->
|
||||
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">
|
||||
|
|
1377
js/cesareBrowse.js
1377
js/cesareBrowse.js
File diff suppressed because it is too large
Load Diff
|
@ -1,2 +1,2 @@
|
|||
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
|
||||
import define from "https://api.observablehq.com/@cesare/dsearchcompare.js?v=3";
|
||||
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@5/dist/runtime.js";
|
||||
import define from "https://api.observablehq.com/@cesare/commarcdiag@564.js?v=3";
|
478
js/utils.js
478
js/utils.js
|
@ -1,37 +1,6 @@
|
|||
|
||||
tq = `
|
||||
PREFIX ecrm: <http://erlangen-crm.org/current/>
|
||||
PREFIX orl: <https://dantenetwork.it/ontology/orl/current/>
|
||||
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
|
||||
PREFIX olires: <https://dantenetwork.it/ontology/olires/current/>
|
||||
PREFIX comm: <http://dantenetwork.it/data/commedia/>
|
||||
SELECT (?form AS ?IRIForma) (?Rappresentazione AS ?Forma) (?lm AS ?Lemma) (?textver AS ?Verso) (?NumVerso AS ?NumeroVerso) (?t_canto AS ?Canto) (?t_cantica AS ?Cantica) WHERE {
|
||||
?fa orl:occurrenceOf ?form .
|
||||
?ver olires:hasStructuralComponent ?fa .
|
||||
?ver ecrm:P190_Has_Symbolic_Content ?textver;
|
||||
olires:hasNumber ?NumVerso.
|
||||
?canto ecrm:P102_has_title ?t_canto;
|
||||
hasStructuralComponent ?ver.
|
||||
?cantica ecrm:P102_has_title ?t_cantica ;
|
||||
hasStructuralComponent ?canto .
|
||||
?form ontolex:writtenRep ?Rappresentazione.
|
||||
?lent ontolex:lexicalForm ?form;
|
||||
ontolex:canonicalForm ?cf.
|
||||
?cf ontolex:writtenRep ?lm.
|
||||
{?form <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> orl:FormaVerboVolgare;
|
||||
orl:TipoDiatesiVerboVolgare orl:VerboVolgareAttivo.
|
||||
}
|
||||
{?form <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> orl:FormaVerboVolgare;
|
||||
orl:TipoDiatesiVerboVolgare orl:VerboVolgareAttivo.
|
||||
{ ?form <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> orl:FormaVerboVolgare;
|
||||
orl:TipoDiatesiVerboVolgare orl:VerboVolgareAttivo.}
|
||||
UNION
|
||||
{ ?form <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> orl:FormaSostantivoVolgare;
|
||||
orl:TipoNumeroSostantivoVolgare orl:NumeroSingolareSostantivoVolgare. }
|
||||
}
|
||||
} ORDER BY (?Cantica) (?Canto)
|
||||
LIMIT 50
|
||||
`
|
||||
|
||||
|
||||
|
||||
tqvpvs=`
|
||||
PREFIX ecrm: <http://erlangen-crm.org/current/>
|
||||
|
@ -153,39 +122,123 @@ PREFIX olires:<https://dantenetwork.it/ontology/olires/current/>
|
|||
PREFIX comm: <http://dantenetwork.it/data/commedia/>
|
||||
PREFIX syntit: <https://dantenetwork.it/ontology/syntit/current/>
|
||||
|
||||
SELECT (?form as ?IRIForma) (?Rappresentazione as ?Forma) (?lm as ?Lemma) (?textver as ?Verso) (?NumVerso as ?NumeroVerso)
|
||||
(?t_canto as ?Canto) (?t_cantica as ?Cantica) ?pos ?clatype ?clafunction ?clfr ?clto ?cl ?sentence
|
||||
SELECT (?t_canto as ?Canto) (?t_cantica as ?Cantica) ?clatype ?clafunction ?clfr ?clto ?cl ?sentence ?cltext ?pos
|
||||
WHERE {
|
||||
FILTER(REGEX(?Rappresentazione, "^andare$", "i")) .
|
||||
FILTER(LANGMATCHES(LANG(?Rappresentazione), "it"))
|
||||
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 orl:occurrenceOf ?form;
|
||||
olires:OccursInRegion ?reg .
|
||||
?ver ecrm:P190_Has_Symbolic_Content ?textver;
|
||||
olires:hasNumber ?NumVerso;
|
||||
olires:hasStructuralComponent ?fa.
|
||||
?reg olires:fragmentRegionFrom ?pos .
|
||||
?canto ecrm:P102_has_title ?t_canto;
|
||||
olires:hasStructuralComponent ?ver.
|
||||
}
|
||||
###end
|
||||
### condizioni comuni
|
||||
?canto ecrm:P102_has_title ?t_canto.
|
||||
?cantica ecrm:P102_has_title ?t_cantica;
|
||||
olires:hasStructuralComponent ?canto.
|
||||
### end
|
||||
###condizioni sintattiche
|
||||
{
|
||||
?clocc orl:occurrenceOf ?cl ;
|
||||
olires:occursInRegion ?frag ;
|
||||
ecrm:P148_has_component ?fa .
|
||||
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
|
||||
}`
|
||||
|
||||
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/>
|
||||
|
||||
SELECT (?t_canto as ?Canto) (?t_cantica as ?Cantica) ?clatype ?clafunction ?clfr ?clto ?cl ?sentence ?cltext ?pos
|
||||
WHERE {
|
||||
FILTER(REGEX(?Rappresentazione, "^buon$", "i")) .
|
||||
FILTER(LANGMATCHES(LANG(?Rappresentazione), "it"))
|
||||
|
||||
### condizioni
|
||||
?canto ecrm:P102_has_title ?t_canto.
|
||||
?cantica ecrm:P102_has_title ?t_cantica;
|
||||
olires:hasStructuralComponent ?canto.
|
||||
###condizioni end
|
||||
###condizioni sintattiche
|
||||
{
|
||||
?clocc orl: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 .
|
||||
}
|
||||
###condizioni sintattiche end
|
||||
}`
|
||||
|
||||
// ?cl syntit:hasClauseType syntit:Dichiarativa.
|
||||
|
||||
ontoSparqlQuerySynt = `
|
||||
PREFIX ecrm: <http://erlangen-crm.org/current/>
|
||||
PREFIX orl: <https://dantenetwork.it/ontology/orl/current/>
|
||||
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
|
||||
PREFIX olires: <https://dantenetwork.it/ontology/olires/current/>
|
||||
PREFIX syntit: <https://dantenetwork.it/ontology/syntit/current/>
|
||||
SELECT ?sentence ?clfr ?clto ?clf ?clatype (?t_canto as ?Canto) (?t_cantica as ?Cantica)
|
||||
WHERE {
|
||||
FILTER regex(?Rappresentazione,"^persona$","i") . #remove if query_text==''
|
||||
FILTER langMatches(lang(?Rappresentazione),"it") #remove if query_text==''
|
||||
?cat ontolex:writtenRep ?Rappresentazione . #remove if query_text==''
|
||||
?fa orl:occurrenceOf ?cat . #remove if query_text==''
|
||||
?clocc ecrm:P148_has_component ?fa . #remove if query_text==''
|
||||
?cl syntit:hasClauseType ?clatype;
|
||||
ecrm:P190_has_symbolic_content ?cltext;
|
||||
syntit:hasClauseFunction ?clf.
|
||||
?clocc orl:occurrenceOf ?cl;
|
||||
olires:occursInRegion ?frag.
|
||||
?frag olires:fragmentRegionFrom ?clfr;
|
||||
olires:fragmentRegionTo ?clto.
|
||||
?sentence <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> syntit:Sentence;
|
||||
ecrm:P148i_is_component_of ?cantoIRI;
|
||||
syntit:hasSyntacticalComponent ?cl.
|
||||
?cantica ecrm:P102_has_title ?t_cantica ;
|
||||
olires:hasStructuralComponent ?cantoIRI .
|
||||
?cantoIRI ecrm:P102_has_title ?t_canto .
|
||||
|
||||
} LIMIT 10000
|
||||
|
||||
`
|
||||
|
||||
|
||||
|
||||
orlprefix = 'https://dantenetwork.it/ontology/orl/current/'
|
||||
|
||||
syntitprefix='https://dantenetwork.it/ontology/syntit/current/'
|
||||
|
@ -195,19 +248,7 @@ var stringInSparql= false;
|
|||
function writesparqlquery(query) {
|
||||
return (query);
|
||||
}
|
||||
// write the query in natural language
|
||||
|
||||
function writesearchValue(form) {
|
||||
var strq = 'il lemma';
|
||||
var strcategoria = 'in tutte le categorie'
|
||||
|
||||
if (form.oggetto.value == 'forma')
|
||||
strq = 'la forma';
|
||||
if (form.categoria.value != 'all')
|
||||
strcategoria = 'nella categoria ' + form.categoria.value;
|
||||
|
||||
return `Cerco: ${strq} ${form.query.value}, ${form.tipo.value}, ${strcategoria}`
|
||||
}
|
||||
|
||||
//restituisce la query per ottenere tutti i versi di una cantica
|
||||
|
||||
|
@ -265,34 +306,44 @@ function getStatements() {
|
|||
return data21
|
||||
|
||||
}
|
||||
|
||||
|
||||
var theguiQ = ''
|
||||
var multipleCondSpQuery = ''
|
||||
var conditions = []
|
||||
var filters = []
|
||||
var unionop = '{"union": {"type": "union", "patterns":[]}, "bgp": {"type": "bgp", "triples":[]}, "group": {"type": "group", "patterns":[]}}'
|
||||
var unionop = `{"union": {"type": "union", "patterns":[]}, "bgp": {"type": "bgp", "triples":[]}, "group": {"type": "group", "patterns":[]}}`
|
||||
|
||||
|
||||
|
||||
function parseJsonClause(op, tokens, nowhere) {
|
||||
//alert(op)
|
||||
var idp=-1
|
||||
if (nowhere[0].type == 'filter' && nowhere[0].expression.args[0].value == 'Rappresentazione'){
|
||||
nowhere.splice(0, 1)
|
||||
}
|
||||
if (op.trim() == 'OR') {
|
||||
//multipleCondSpQuery.where.push(JSON.parse(unionop)['union']);
|
||||
nowhere.push(JSON.parse(unionop)['union']);
|
||||
//nowhere.unshift(JSON.parse(unionop)['union']);
|
||||
nowhere.splice(1, 0, JSON.parse(unionop)['union'])
|
||||
idp=1
|
||||
}
|
||||
if (op.trim() == 'AND') {
|
||||
nowhere.push(JSON.parse(unionop)['group']);
|
||||
//nowhere.push(JSON.parse(unionop)['group']);
|
||||
nowhere.splice(1, 0, JSON.parse(unionop)['group'])
|
||||
idp=1
|
||||
|
||||
}
|
||||
for (var mtoken in tokens) {
|
||||
te_op = tokens[mtoken]
|
||||
if ('TERM' in te_op) {
|
||||
cond = theguiQ[te_op['TERM']]
|
||||
//parsedquery.where.at(-1).patterns
|
||||
multipleCondSpQuery = buildJsonClause(cond, multipleCondSpQuery, -1, nowhere.at(-1).patterns)
|
||||
//mywhere=nowhere[idp].patterns;
|
||||
multipleCondSpQuery = buildStatementClause (cond, multipleCondSpQuery, -1, nowhere[idp].patterns)
|
||||
|
||||
}
|
||||
else
|
||||
parseJsonClause(Object.keys(te_op)[0], te_op[Object.keys(te_op)[0]], nowhere.at(-1).patterns)
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -302,8 +353,8 @@ function buildSPQuery(guiquery) {
|
|||
theguiQ = guiquery;
|
||||
var SparqlParser = sparqljs.Parser;
|
||||
var spqparser = new SparqlParser();
|
||||
multipleCondSpQuery = spqparser.parse(ontoSparqlQuery);
|
||||
mytestq = spqparser.parse(tq);
|
||||
multipleCondSpQuery = spqparser.parse(ontoSparqlQueryMultCond);
|
||||
//mytestq = spqparser.parse(tq);
|
||||
var parser = peg.generate(hdnquerygrammar);
|
||||
test = guiquery['EsprLogica'].join(" ");
|
||||
test = test.replaceAll("( ", "(")
|
||||
|
@ -327,20 +378,24 @@ function buildSQ(stquery) {
|
|||
var SparqlParser = sparqljs.Parser;
|
||||
var parser = new SparqlParser();
|
||||
//Prendo la query SPARQL template
|
||||
const parsedquery = parser.parse(ontoSparqlQuery);
|
||||
var parsedquery = parser.parse(ontoSparqlQuery);
|
||||
//const parsedquery = parser.parse(tqvpvs);
|
||||
|
||||
console.log(stquery)
|
||||
|
||||
|
||||
if (stquery['EsprLogica'] != null && stquery['EsprLogica'].length > 1) {
|
||||
parsedquery=parser.parse(ontoSparqlQueryMultCond)
|
||||
buildSPQuery(stquery)
|
||||
return multipleCondSpQuery;
|
||||
}
|
||||
|
||||
if (stquery['EsprLogica'] != null && stquery['EsprLogica'] != '' && stquery['EsprLogica'].length == 1) {
|
||||
clause = stquery['EsprLogica']
|
||||
|
||||
if (stquery[clause]['TipoClausola']=='Sintattico'){
|
||||
parsedquery = parser.parse(ontoSparqlQuerySynt);
|
||||
return buildSintacticClause(stquery[clause], parsedquery, 2)
|
||||
}
|
||||
myquery = buildClause(stquery[clause], parsedquery, 2)
|
||||
return (myquery)
|
||||
}
|
||||
|
@ -376,42 +431,35 @@ function buildSQ(stquery) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
function buildJsonClause(clause, parsedquery, whereind, theplace) {
|
||||
//Nick
|
||||
if (clause['categoria'] != null){
|
||||
clause['typeGramm0']=clause['categoria'];
|
||||
clause['queryText']=clause['query']
|
||||
function buildStatementClause (clause, parsedquery, whereind, theplace) {
|
||||
//var tmpgroup=JSON.parse(unionop)['group']
|
||||
if (clause['TipoClausola']=="Sintattico"){
|
||||
//tmpgroup=JSON.parse(unionop)['group']
|
||||
tmpgroup=JSON.parse(syntgroup)
|
||||
}
|
||||
else tmpgroup=JSON.parse(morphgroup);
|
||||
|
||||
if (clause['queryText']!=null && clause['queryText'].trim() != "") {
|
||||
if (clause['queryText'].trim().slice(-1) !== '*')
|
||||
strval = "^" + clause['queryText'].trim() + "$";
|
||||
else
|
||||
strval = clause['queryText'].trim().slice(0, -1)
|
||||
if (clause['queryText']!=null && clause['queryText'].trim() != ""){
|
||||
//theplace.push(JSON.parse(unionop)['group']);
|
||||
|
||||
parsedquery.where[1].expression.args[1].value = strval;
|
||||
if (clause['lemma_forma'] == 'lemma')
|
||||
parsedquery.where[1].expression.args[0].value = "lm";
|
||||
var stmt=buildFilterStatement(clause['lemma_forma'], clause['queryText'].trim(), clause['opzioni_testo'])
|
||||
tmpgroup.patterns.push(stmt)
|
||||
tmpgroup.patterns.push(JSON.parse(unionop)['bgp']);
|
||||
tmpgroup.patterns.at(-1).triples.push(JSON.parse(writtenrepresentation))
|
||||
}
|
||||
else {
|
||||
if (parsedquery.where[1].type == 'filter' && parsedquery.where[1].expression.args[0].value == 'Rappresentazione')
|
||||
parsedquery.where.splice(1, 1)
|
||||
}
|
||||
|
||||
if (clause['typeGramm0'] != null && clause['typeGramm0'] != "all")
|
||||
if (whereind > -1)
|
||||
parsedquery.where[whereind].triples.push(JSON.parse(data21)[clause['typeGramm0']]);
|
||||
else {
|
||||
//parsedquery.where.at(-1).patterns
|
||||
theplace.push(JSON.parse(unionop)['bgp']);
|
||||
theplace.at(-1).triples.push(JSON.parse(data21)[clause['typeGramm0']]);
|
||||
//theplace.push(JSON.parse(unionop)['bgp']);
|
||||
//theplace.at(-1).triples.push(JSON.parse(data21)[clause['typeGramm0']]);
|
||||
tmpgroup.patterns.push(JSON.parse(unionop)['bgp']);
|
||||
tmpgroup.patterns.at(-1).triples.push(JSON.parse(data21)[clause['typeGramm0']]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (clause['typeGramm0'] != null && Object.keys(sottoCategorie).includes(clause['typeGramm0'].trim())) {
|
||||
//sctmp=JSON.parse(sottoCategorieSostantivi)
|
||||
|
||||
sctmp = sottoCategorie[clause['typeGramm0'].trim()]
|
||||
sctk = Object.keys(sctmp)
|
||||
for (ke in sctk) {
|
||||
|
@ -424,60 +472,88 @@ function buildJsonClause(clause, parsedquery, whereind, theplace) {
|
|||
if (whereind > -1)
|
||||
parsedquery.where[whereind].triples.push(subcatstat);
|
||||
else
|
||||
theplace.at(-1).triples.push(subcatstat);
|
||||
//theplace.at(-1).triples.push(subcatstat);
|
||||
tmpgroup.patterns.at(-1).triples.push(subcatstat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (clause['TipoClausola']=="Sintattico"){
|
||||
tmpgroup.patterns.push(JSON.parse(unionop)['bgp']);
|
||||
var functS=clause['functionSyntax'];
|
||||
var typeS=clause['typeSyntax0']
|
||||
console.log(functS+' '+typeS)
|
||||
if (functS != null && functS != ".+"){
|
||||
var myf=buildsyntClause(funzione_clausola[functS])
|
||||
if (myf!='')
|
||||
tmpgroup.patterns.at(-1).triples.push(myf)
|
||||
}
|
||||
if (typeS != null && typeS != ".+"){
|
||||
myf=buildsyntClause(macrotipi_sint[typeS])
|
||||
if (myf!='')
|
||||
tmpgroup.patterns.at(-1).triples.push(myf)
|
||||
}
|
||||
}
|
||||
|
||||
theplace.push(tmpgroup)
|
||||
return parsedquery
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function buildSintacticClause(clause, parsedquery, whereind) {
|
||||
|
||||
var functS=clause['functionSyntax'];
|
||||
var typeS=clause['typeSyntax0']
|
||||
if (functS != null && functS != "all"){
|
||||
console.log('functS '+funzione_clausola['princ'])
|
||||
var myf=buildsyntClause(funzione_clausola[functS])
|
||||
console.log('myf '+myf)
|
||||
if (myf=='')
|
||||
return parsedquery
|
||||
if (whereind > -1)
|
||||
parsedquery.where[whereind].triples.push(myf);
|
||||
else
|
||||
parsedquery.where.at(-1).patterns.at(-1).triples.push(myf);
|
||||
}
|
||||
return parsedquery
|
||||
}
|
||||
|
||||
function buildClause(clause, parsedquery, whereind) {
|
||||
|
||||
if (clause['queryText'].trim() != "") {
|
||||
if (clause['queryText'].trim().slice(-1) !== '*')
|
||||
strval = "^" + clause['queryText'].trim() + "$";
|
||||
else
|
||||
strval = clause['queryText'].trim().slice(0, -1)
|
||||
|
||||
var strval= getStringFilter(clause['queryText'].trim(), clause['opzioni_testo'])
|
||||
parsedquery.where[0].expression.args[1].value = strval;
|
||||
if (clause['lemma_forma'] == 'lemma')
|
||||
parsedquery.where[0].expression.args[0].value = "lm";
|
||||
}
|
||||
else {
|
||||
if (parsedquery.where[0].type == 'filter' && parsedquery.where[0].expression.args[0].value == 'Rappresentazione')
|
||||
//remove the filter for text CHANGE!
|
||||
parsedquery.where.splice(0, 1)
|
||||
parsedquery.where.splice(0, 1)
|
||||
parsedquery.where[0].triples.splice(2,1)
|
||||
parsedquery.where[0].triples.splice(1,1)
|
||||
parsedquery.where[0].triples.splice(0,1)
|
||||
whereind=whereind-1
|
||||
}
|
||||
|
||||
|
||||
var functS=clause['functionSyntax'];
|
||||
var typeS=clause['typeSyntax0']
|
||||
console.log(functS+' '+typeS)
|
||||
if (functS != null && functS != ".+"){
|
||||
//console.log('functS '+funzione_clausola['princ'])
|
||||
var myf=buildsyntClause(funzione_clausola[functS])
|
||||
|
||||
if (myf=='')
|
||||
return parsedquery
|
||||
parsedquery.where.at(-1).triples.push(myf);
|
||||
}
|
||||
if (typeS != null && typeS != ".+"){
|
||||
myf=buildsyntClause(macrotipi_sint[typeS])
|
||||
parsedquery.where.at(-1).triples.push(myf);
|
||||
}
|
||||
return parsedquery
|
||||
}
|
||||
|
||||
function buildClause(clause, parsedquery, whereind) {
|
||||
|
||||
if (clause['TipoClausola']=='Sintattico')
|
||||
return buildSintacticClause(clause, parsedquery, whereind)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (clause['typeGramm0'] != null && clause['typeGramm0'] != "all")
|
||||
if (whereind > -1)
|
||||
//parsedquery.where[whereind].triples.push(JSON.parse(data21)[clause['typeGramm0']]);
|
||||
parsedquery.where[whereind].triples.splice(0, 0, JSON.parse(data21)[clause['typeGramm0']]);
|
||||
parsedquery.where[2].patterns[0].triples.splice(0, 0, JSON.parse(data21)[clause['typeGramm0']]);
|
||||
else {
|
||||
parsedquery.where.at(-1).patterns.push(JSON.parse(unionop)['bgp']);
|
||||
parsedquery.where.at(-1).patterns.at(-1).triples.push(JSON.parse(data21)[clause['typeGramm0']]);
|
||||
|
@ -496,7 +572,7 @@ function buildClause(clause, parsedquery, whereind) {
|
|||
if (sttmts[keval] != null && (sttmts[keval].split(':')[1]) != null) {
|
||||
subcatstat = buildsubcategoryClause(sttmts[keval])
|
||||
if (whereind > -1)
|
||||
parsedquery.where[whereind].triples.push(subcatstat);
|
||||
parsedquery.where[2].patterns[0].triples.push(subcatstat);
|
||||
else
|
||||
parsedquery.where.at(-1).patterns.at(-1).triples.push(subcatstat);
|
||||
}
|
||||
|
@ -504,11 +580,96 @@ function buildClause(clause, parsedquery, whereind) {
|
|||
}
|
||||
}
|
||||
|
||||
if (clause['queryText'].trim() != "") {
|
||||
|
||||
var strval= getStringFilter(clause['queryText'].trim(), clause['opzioni_testo'])
|
||||
parsedquery.where[0].expression.args[1].value = strval;
|
||||
if (clause['lemma_forma'] == 'lemma')
|
||||
parsedquery.where[0].expression.args[0].value = "lm";
|
||||
}
|
||||
else {
|
||||
if (parsedquery.where[0].type == 'filter' && parsedquery.where[0].expression.args[0].value == 'Rappresentazione')
|
||||
parsedquery.where.splice(0, 1)
|
||||
whereind=whereind-1
|
||||
}
|
||||
|
||||
return parsedquery
|
||||
|
||||
}
|
||||
|
||||
function getStringFilter(filter, opzione){
|
||||
var strval = "^" + filter.trim() + "$";
|
||||
if (opzione != "")
|
||||
switch (opzione) {
|
||||
case 'parola':
|
||||
strval = "^" + filter.trim() + "$";
|
||||
break;
|
||||
case 'sottostringa':
|
||||
strval = filter.trim();
|
||||
break;
|
||||
case 'prefisso':
|
||||
strval = "^" + filter.trim();
|
||||
break;
|
||||
case 'suffisso':
|
||||
strval = filter.trim() + "$";
|
||||
break;
|
||||
default:
|
||||
strval = "^" + filter.trim() + "$";
|
||||
|
||||
};
|
||||
return (strval)
|
||||
}
|
||||
function buildFilterStatement(target, filter, opzione){
|
||||
|
||||
var filtertemplate = `{
|
||||
"type": "filter",
|
||||
"expression": {
|
||||
"type": "operation",
|
||||
"operator": "regex",
|
||||
"args": [
|
||||
{
|
||||
"termType": "Variable",
|
||||
"value": "Rappresentazione"
|
||||
},
|
||||
{
|
||||
"termType": "Literal",
|
||||
"value": "^andare$",
|
||||
"language": "",
|
||||
"datatype": {
|
||||
"termType": "NamedNode",
|
||||
"value": "http://www.w3.org/2001/XMLSchema#string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"termType": "Literal",
|
||||
"value": "i",
|
||||
"language": "",
|
||||
"datatype": {
|
||||
"termType": "NamedNode",
|
||||
"value": "http://www.w3.org/2001/XMLSchema#string"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}`
|
||||
|
||||
|
||||
var statement = JSON.parse(filtertemplate)
|
||||
/*
|
||||
if (filter.trim().slice(-1) !== '*')
|
||||
strval = "^" + filter.trim() + "$";
|
||||
else
|
||||
strval = filter.trim().slice(0, -1)
|
||||
*/
|
||||
var strval = getStringFilter(filter, opzione);
|
||||
|
||||
statement.expression.args[1].value = strval;
|
||||
if (target == 'lemma')
|
||||
statement.expression.args[0].value = "lm";
|
||||
|
||||
return (statement)
|
||||
}
|
||||
|
||||
function buildsyntClause(sttmnt) {
|
||||
|
||||
var tmplate = `{"subject": {"termType": "Variable", "value":"cl"},
|
||||
|
@ -840,7 +1001,11 @@ var sottoCategorie = {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* SPARQL statements
|
||||
*
|
||||
*/
|
||||
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": "https://dantenetwork.it/ontology/orl/current/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": "https://dantenetwork.it/ontology/orl/current/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": "https://dantenetwork.it/ontology/orl/current/FormaAggettivoVolgare"}},
|
||||
|
@ -856,6 +1021,83 @@ data21 = `{"verbovolgare": {"subject": {"termType": "Variable", "value":"form"},
|
|||
}
|
||||
`
|
||||
|
||||
writtenrepresentation=`{"subject": {"termType": "Variable", "value":"form"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#writtenRep"}, "object": {"termType": "Variable", "value": "Rappresentazione"}}`
|
||||
|
||||
|
||||
var morphgroup=`{"type": "group",
|
||||
"patterns": [{"type": "bgp",
|
||||
"triples": [
|
||||
{"subject": {"termType": "Variable","value": "form"},
|
||||
"predicate": {"termType": "NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#writtenRep"},
|
||||
"object": {"termType": "Variable","value": "Rappresentazione"}},
|
||||
{"subject": {"termType": "Variable","value": "lent"},
|
||||
"predicate": {"termType": "NamedNode","value": "http://www.w3.org/ns/lemon/ontolex#lexicalForm"},
|
||||
"object": {"termType": "Variable", "value": "form"}},
|
||||
{"subject": {"termType": "Variable","value": "lent"},
|
||||
"predicate": {"termType": "NamedNode","value": "http://www.w3.org/ns/lemon/ontolex#canonicalForm"},
|
||||
"object": {"termType": "Variable","value": "cf"}},
|
||||
{"subject": {"termType": "Variable","value": "cf"},
|
||||
"predicate": {"termType": "NamedNode","value": "http://www.w3.org/ns/lemon/ontolex#writtenRep"},
|
||||
"object": {"termType": "Variable","value": "lm"}},
|
||||
{"subject": {"termType": "Variable","value": "fa"},
|
||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/orl/current/occurrenceOf"},
|
||||
"object": {"termType": "Variable","value": "form"}},
|
||||
{"subject": {"termType": "Variable","value": "fa"},
|
||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/OccursInRegion"},
|
||||
"object": {"termType": "Variable", "value": "reg"}},
|
||||
{"subject": {"termType": "Variable","value": "reg"},
|
||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/fragmentRegionFrom"},
|
||||
"object": {"termType": "Variable","value": "pos"}}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
`
|
||||
var syntgroup=` {
|
||||
"type": "group",
|
||||
"patterns": [
|
||||
{
|
||||
"type": "bgp",
|
||||
"triples": [
|
||||
{"subject": {"termType": "Variable","value": "clocc"},
|
||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/orl/current/occurrenceOf"},
|
||||
"object": {"termType": "Variable","value": "cl"}},
|
||||
{"subject": {"termType": "Variable","value": "clocc"},
|
||||
"predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P148_has_component"},
|
||||
"object": {"termType": "Variable","value": "fa"}},
|
||||
{"subject": {"termType": "Variable","value": "clocc"},
|
||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occursInRegion"},
|
||||
"object": {"termType": "Variable","value": "frag"}},
|
||||
{"subject": {"termType": "Variable","value": "sentence"},
|
||||
"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/Sentence"}},
|
||||
{"subject": {"termType": "Variable","value": "sentence"},
|
||||
"predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P148i_is_component_of"},
|
||||
"object": {"termType": "Variable","value": "canto"}},
|
||||
{"subject": {"termType": "Variable","value": "sentence"},
|
||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasSyntacticalComponent"},
|
||||
"object": {"termType": "Variable","value": "cl"}},
|
||||
{"subject": {"termType": "Variable","value": "cl"},
|
||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasClauseType"},
|
||||
"object": {"termType": "Variable","value": "clatype"}},
|
||||
{"subject": {"termType": "Variable","value": "cl"},
|
||||
"predicate": {"termType": "NamedNode","value": "http://erlangen-crm.org/current/P190_has_symbolic_content"},
|
||||
"object": {"termType": "Variable","value": "cltext"}},
|
||||
{"subject": {"termType": "Variable","value": "cl"},
|
||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasClauseFunction"},
|
||||
"object": {"termType": "Variable","value": "clafunction"}},
|
||||
{"subject": {"termType": "Variable","value": "frag"},
|
||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/fragmentRegionFrom"},
|
||||
"object": {"termType": "Variable","value": "clfr"}},
|
||||
{"subject": {"termType": "Variable","value": "frag"},
|
||||
"predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/fragmentRegionTo"},
|
||||
"object": {"termType": "Variable","value": "clto"}}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
`
|
||||
/*
|
||||
*
|
||||
*Tipi sintattici
|
||||
|
|
Loading…
Reference in New Issue