implementazione ricerca avanzata, in progress

This commit is contained in:
cesare 2025-02-06 12:53:36 +01:00
parent 415691f7fc
commit 8f66ce7848
3 changed files with 58 additions and 56 deletions

View File

@ -1,7 +1,7 @@
/** /**
* *
*/ */
import { getVersiConCitazioni, queryRiferimenti, getListaRis, cleanListaRis, getFormaCntxt, getListaIdCommenti} from './dataMgr.js'; import { getVersiConCitazioni, queryRiferimenti, getListaRis, cleanListaRis, getFormaCntxt, getListaIdCommenti} from './dataMgr_5.0.js';
import { getJsonQuery, emptyStructCard } from './script_5.0.js'; import { getJsonQuery, emptyStructCard } from './script_5.0.js';
import {resetGraphStr} from './syntgraph_5.0.js' import {resetGraphStr} from './syntgraph_5.0.js'

View File

@ -5,7 +5,7 @@
import {numeroContesti, resetResult, showOffset} from './browseMgr_5.0.js' import {numeroContesti, resetResult, showOffset} from './browseMgr_5.0.js'
import { resetGraphStr } from './syntgraph_5.0.js'; import { resetGraphStr } from './syntgraph_5.0.js';
import { getAutoriFontiCitazioniS, getCommentatoriS, getAreeTematicheS, getFontiS} from './dataMgr.js'; import { getAutoriFontiCitazioniS, getCommentatoriS, getAreeTematicheS, getFontiS} from './dataMgr_5.0.js';
export var getJsonQuery; export var getJsonQuery;
export var fillStructCard; export var fillStructCard;

View File

@ -413,7 +413,7 @@ function buildSPQuery(guiquery) {
parseJsonClause(ck, jsonclauses[ck], multipleCondSpQuery.where) parseJsonClause(ck, jsonclauses[ck], multipleCondSpQuery.where)
} }
if (theguiQ['unitaRicerca'] == 'periodo' || theguiQ['unitaRicerca'] == 'frase'|| theguiQ['unitaRicerca'] == 'verso') { if (theguiQ['unitaRicerca'] == 'periodo' || theguiQ['unitaRicerca'] == 'frase' || theguiQ['unitaRicerca'] == 'verso') {
multipleCondSpQuery.where.push(bindConcatStatement) multipleCondSpQuery.where.push(bindConcatStatement)
multipleCondSpQuery.where.push(occBindConcatStatement) multipleCondSpQuery.where.push(occBindConcatStatement)
@ -444,7 +444,7 @@ function buildSQ(stquery) {
buildSPQuery(stquery) buildSPQuery(stquery)
return multipleCondSpQuery; return multipleCondSpQuery;
} }
var clausolaS='Clausola0'
if (stquery['QueryAvanzata'] == 1 && stquery['EsprLogica'] != null && stquery['EsprLogica'] != '' && stquery['EsprLogica'].length == 1) { if (stquery['QueryAvanzata'] == 1 && stquery['EsprLogica'] != null && stquery['EsprLogica'] != '' && stquery['EsprLogica'].length == 1) {
clause = stquery['EsprLogica'] clause = stquery['EsprLogica']
@ -452,8 +452,8 @@ function buildSQ(stquery) {
if (((stquery[clause]['typeSyntax0'].trim() != '' && stquery[clause]['typeSyntax0'].trim() != '.+') || if (((stquery[clause]['typeSyntax0'].trim() != '' && stquery[clause]['typeSyntax0'].trim() != '.+') ||
stquery[clause]['functionSyntax'].trim() != '.+') && stquery[clause]['functionSyntax'].trim() != '.+') &&
stquery[clause]['typeGramm0'].trim() == 'all') {//solo filtro sintattico stquery[clause]['typeGramm0'].trim() == 'all') {//solo filtro sintattico
parsedquery = parser.parse(ontoSparqlQuerySynt); parsedquery = parser.parse(ontoSparqlQuerySynt);
var tempsyntquery = buildSintacticClause(stquery[clause], parsedquery, 2) var tempsyntquery = buildSintacticClause(stquery[clause], parsedquery, 2)
if (filtroContesto.length > 0) { if (filtroContesto.length > 0) {
@ -464,7 +464,7 @@ function buildSQ(stquery) {
return tempsyntquery return tempsyntquery
} }
if ((stquery[clause]['typeSyntax0'].trim() == '.+' && stquery[clause]['functionSyntax'].trim() == '.+') && if ((stquery[clause]['typeSyntax0'].trim() == '.+' && stquery[clause]['functionSyntax'].trim() == '.+') &&
stquery[clause]['typeGramm0'].trim() != 'all') {//solo filtro grammaticale stquery[clause]['typeGramm0'].trim() != 'all') {//solo filtro grammaticale
myquery = buildClause(stquery[clause], parsedquery, 2) myquery = buildClause(stquery[clause], parsedquery, 2)
if (filtroContesto.length > 0) { if (filtroContesto.length > 0) {
for (tmpc of filtroContesto) { for (tmpc of filtroContesto) {
@ -482,50 +482,52 @@ function buildSQ(stquery) {
} }
if (((stquery[clause]['typeSyntax0'].trim() != '' && stquery[clause]['typeSyntax0'].trim() != '.+') || if (((stquery[clause]['typeSyntax0'].trim() != '' && stquery[clause]['typeSyntax0'].trim() != '.+') ||
(stquery[clause]['functionSyntax'].trim() != '' && stquery[clause]['functionSyntax'].trim() != '.+')) && (stquery[clause]['functionSyntax'].trim() != '' && stquery[clause]['functionSyntax'].trim() != '.+')) &&
stquery[clause]['typeGramm0'].trim() != 'all') {//entrambi i filtri stquery[clause]['typeGramm0'].trim() != 'all') {//entrambi i filtri
console.log('entrambi i filtri') console.log('entrambi i filtri')
//preparo la query sparql //preparo la query sparql
var tmpCont=stquery[clause]['contesto'] var tmpCont = stquery[clause]['contesto']
var tmpCl0=stquery['Clausola0'] var tmpCl0 = stquery['Clausola0']
var tmpUnric=stquery['unitaRicerca'] var tmpUnric = stquery['unitaRicerca']
var tmpCl2= { var tmpCl2 = {
"queryText": stquery[clause]["queryText"], "queryText": stquery[clause]["queryText"],
"lemma_forma": stquery[clause]["lemma_forma"], "lemma_forma": stquery[clause]["lemma_forma"],
"opzioni_testo": stquery[clause]["opzioni_testo"], "opzioni_testo": stquery[clause]["opzioni_testo"],
"TipoClausola": "Sintattico", "TipoClausola": "Sintattico",
"Attiva": "1", "Attiva": "1",
"typeSyntax0": stquery[clause]["typeSyntax0"], "typeSyntax0": stquery[clause]["typeSyntax0"],
"functionSyntax": stquery[clause]["functionSyntax"], "functionSyntax": stquery[clause]["functionSyntax"],
"contesto": tmpCont "contesto": tmpCont
} }
var tmpCl1J = stquery['Clausola1']
//var tmpCl1J= JSON.parse(tC1);
delete tmpCl1J['typeSyntax0'];
delete tmpCl1J['functionSyntax'];
tmpCl1J["TipoClausola"] = "Grammaticale"
var tmpJ = {
"EsprLogica": ["(", "AND", "Clausola1", "Clausola2", ")"],
"LogicaGui": ["(", "AND", "Clausola1", "Clausola2", ")"],
"QueryAvanzata": "1",
"unitaRicerca": tmpUnric,
"LiDaVersion": "1.0",
"Clausola0": tmpCl0,
"Clausola1": tmpCl1J,
"Clausola2": tmpCl2
}
console.log(tmpJ);
buildSPQuery(tmpJ);
return multipleCondSpQuery;
var tmpCl1J=stquery['Clausola1']
//var tmpCl1J= JSON.parse(tC1);
delete tmpCl1J['typeSyntax0'];
delete tmpCl1J['functionSyntax'];
tmpCl1J["TipoClausola"]="Grammaticale"
var tmpJ={
"EsprLogica": ["(","AND","Clausola1","Clausola2",")"],
"LogicaGui": ["(","AND","Clausola1","Clausola2",")"],
"QueryAvanzata": "1",
"unitaRicerca": tmpUnric,
"LiDaVersion": "1.0",
"Clausola0": tmpCl0,
"Clausola1":tmpCl1J,
"Clausola2": tmpCl2
} }
console.log(tmpJ); if (stquery[clause]['queryText'].trim() != "")
buildSPQuery(tmpJ); clausolaS=clause
return multipleCondSpQuery;
}
} }
//Simple query //Simple query
filtroContestoJson = getFiltroContestoJson(JSON.parse(stquery['Clausola0']['contesto'])) filtroContestoJson = getFiltroContestoJson(JSON.parse(stquery[clausolaS]['contesto']))
if (filtroContestoJson.length > 0) { if (filtroContestoJson.length > 0) {
for (tmpc of filtroContestoJson) { for (tmpc of filtroContestoJson) {
//console.log(filtroContesto[0]) //console.log(filtroContesto[0])
@ -535,20 +537,20 @@ function buildSQ(stquery) {
} }
if (stquery['Clausola0']['queryText'] != "" && stquery['Clausola0']['Attiva'] == 1) { if (stquery[clausolaS]['queryText'] != "" && stquery[clausolaS]['Attiva'] == 1) {
searchtext = stquery['Clausola0']['queryText'] searchtext = stquery[clausolaS]['queryText']
let strval = "^" + searchtext.trim() + "$" let strval = "^" + searchtext.trim() + "$"
if (stquery['Clausola0']['opzioni_testo'] == 'parola') { if (stquery[clausolaS]['opzioni_testo'] == 'parola') {
strval = "^" + searchtext.trim() + "$"; strval = "^" + searchtext.trim() + "$";
} }
if (stquery['Clausola0']['opzioni_testo'] == 'sottostringa') { if (stquery[clausolaS]['opzioni_testo'] == 'sottostringa') {
strval = searchtext.trim(); strval = searchtext.trim();
} }
if (stquery['Clausola0']['opzioni_testo'] == 'suffisso') { if (stquery[clausolaS]['opzioni_testo'] == 'suffisso') {
strval = searchtext.trim() + "$"; strval = searchtext.trim() + "$";
} }
if (stquery['Clausola0']['opzioni_testo'] == 'prefisso') { if (stquery[clausolaS]['opzioni_testo'] == 'prefisso') {
strval = "^" + searchtext.trim(); strval = "^" + searchtext.trim();
} }
@ -556,7 +558,7 @@ function buildSQ(stquery) {
parsedquery.where[0].expression.args[1].value = strval; parsedquery.where[0].expression.args[1].value = strval;
if (stquery['Clausola0']['lemma_forma'] == 'lemma') { if (stquery[clausolaS]['lemma_forma'] == 'lemma') {
parsedquery.where[0].expression.args[0].value = "lm"; parsedquery.where[0].expression.args[0].value = "lm";
parsedquery.where.splice(1, 1) parsedquery.where.splice(1, 1)
parsedquery.where[1].patterns[0].triples.splice(0, 1) parsedquery.where[1].patterns[0].triples.splice(0, 1)