/** * */ //query per le simple search con condizioni sulla clausola grammaticale var ontoSparqlQuery = `PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX ecrm: <https://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/> prefix tresont: <https://itserr.it/tresont/current/> SELECT (?t_canto as ?Canto) (?t_cantica as ?Cantica) ?clatype ?clafunction ?clfr ?clto ?cl ?sentence ?cltext ?pos ?clocc ?nv WHERE { 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 olires:occurrenceOf ?form; olires:OccursInRegion ?reg . ?reg olires:fragmentRegionFrom ?pos . ?ve olires:hasStructuralComponent ?fa; olires:hasNumber ?nv. } ###end ###condizioni sintattiche { ?clocc olires:occurrenceOf ?cl ; 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 ### condizioni comuni ?canto ecrm:P102_has_title ?t_canto; olires:hasNumber ?num . ?cantica ecrm:P102_has_title ?t_cantica; olires:hasStructuralComponent ?canto. # FILTER (?t_cantica in ("Inferno", "Purgatorio")) # FILTER (?num IN ("12"^^xsd:short, "4"^^xsd:short ) ) ### end }` //Query generica per advanced search con piu condizioni var ontoSparqlQueryMultCond = `PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 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/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix tresont: <https://itserr.it/tresont/current/> PREFIX ecrm: <https://erlangen-crm.org/current/> SELECT (?t_canto as ?Canto) (?t_cantica as ?Cantica) ?clatype ?clafunction ?clfr ?clto ?cl ?sentence ?pos ?clocc WHERE { FILTER(REGEX(?Rappresentazione, "^buon$", "i")) . FILTER(LANGMATCHES(LANG(?Rappresentazione), "it")) ### condizioni ?canto ecrm:P102_has_title ?t_canto; olires:hasNumber ?num . ?cantica ecrm:P102_has_title ?t_cantica; olires:hasStructuralComponent ?canto. ###condizioni end ###condizioni sintattiche { ?clocc olires: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 . #?frag olires:fragmentRegionFrom ?pos. } ###condizioni sintattiche end BIND(COALESCE(?pos1,-1) AS ?pos) }` //Query per advanced search con obiettivo = 'Verso' const versotargetquery = ` PREFIX ecrm: <https://erlangen-crm.org/current/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX olires: <https://dantenetwork.it/ontology/olires/current/> PREFIX syntit: <https://dantenetwork.it/ontology/syntit/current/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX lemon: <http://lemon-model.net/lemon#> PREFIX orl: <https://dantenetwork.it/ontology/orl/current/> PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#> prefix tresont: <https://itserr.it/tresont/current/> SELECT distinct (?t_canto AS ?Canto) (?t_cantica AS ?Cantica) ?sentence ?clfr ?clto ?clafunction ?clt ?pos WHERE { ?verso olires:OccursInRegion ?regver. ?regver olires:fragmentRegionFrom ?clfr; olires:fragmentRegionTo ?clto. ?canto olires:hasStructuralComponent ?verso; ecrm:P102_has_title ?t_canto; olires:hasNumber ?num. ?cantica ecrm:P102_has_title ?t_cantica; olires:hasStructuralComponent ?canto. }` //Query per advanced search con obiettivo = 'Frase' const clausetargetquery = ` PREFIX ecrm: <https://erlangen-crm.org/current/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX olires: <https://dantenetwork.it/ontology/olires/current/> PREFIX syntit: <https://dantenetwork.it/ontology/syntit/current/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX lemon: <http://lemon-model.net/lemon#> PREFIX orl: <https://dantenetwork.it/ontology/orl/current/> PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#> prefix tresont: <https://itserr.it/tresont/current/> SELECT distinct (?t_canto AS ?Canto) (?t_cantica AS ?Cantica) ?sentence ?clfr ?clto ?clafunction ?clt ?pos WHERE { { ?sentence rdf:type syntit:Sentence; syntit:hasSyntacticalComponent ?cl; ecrm:P148i_is_component_of ?canto. ?cl syntit:hasClauseType ?clatype; syntit:hasClauseFunction ?clafun. #?seocc olires:occurrenceOf ?sentence; # olires:occursInRegion ?frag. ?claocc olires:occurrenceOf ?cl; olires:occursInRegion ?fragcl. ?fragcl olires:fragmentRegionFrom ?clfr; olires:fragmentRegionTo ?clto. } ?canto ecrm:P102_has_title ?t_canto; olires:hasNumber ?num. ?cantica ecrm:P102_has_title ?t_cantica; olires:hasStructuralComponent ?canto. BIND(CONCAT(STR(?clafun), ';') AS ?clafunction) BIND(STR(?clatype) AS ?clt) #FILTER (?clto > ?pos && ?clfr<?pos) . }` //bindConcatStatement const clausetarget_functionbind = `{ "type": "bind", "variable": { "termType": "Variable", "value": "clafun" }, "expression": { "type": "operation", "operator": "concat", "args": [] } }` //clauseTypeBindStatement const clausetarget_typebind = `{ "type": "bind", "variable": { "termType": "Variable", "value": "clatype" }, "expression": { "type": "operation", "operator": "", "args": [] } }` /* */ //clausePosCoalesceStatement const clausetarget_coalesce = `{ "type": "bind", "variable": { "termType": "Variable", "value": "pos" }, "expression": { "type": "operation", "operator": "coalesce", "args": [] } }` const clausepos_gr_filter=` { "type": "filter", "expression": { "type": "operation", "operator": "&&", "args": [ { "type": "operation", "operator": ">=", "args": [ { "termType": "Variable", "value": "clto" }, { "termType": "Variable", "value": "pos_" } ] }, { "type": "operation", "operator": "<=", "args": [ { "termType": "Variable", "value": "clfr" }, { "termType": "Variable", "value": "pos_" } ] } ] } } ` //TEST per posizione in frase /* "language": "", "datatype": { "termType": "NamedNode", "value": "http://www.w3.org/2001/XMLSchema#integer" } */ const formapos_verso_filter=` { "type": "filter", "expression": { "type": "operation", "operator": "=", "args": [] } }` const formapos_frase_filter=` { "type": "filter", "expression": { "type": "operation", "operator": "&&", "args": [ { "type": "operation", "operator": ">=", "args": [ { "termType": "Literal", "value": "_999_", "language": "", "datatype": { "termType": "NamedNode", "value": "http://www.w3.org/2001/XMLSchema#int" } }, { "termType": "Variable", "value": "seqpos_" } ] }, { "type": "operation", "operator": "<=", "args": [ { "termType": "Literal", "value": "_0_", "language": "", "datatype": { "termType": "NamedNode", "value": "http://www.w3.org/2001/XMLSchema#int" } }, { "termType": "Variable", "value": "seqpos_" } ] } ] } }` 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' const sentencetargetquery = ` PREFIX ecrm: <https://erlangen-crm.org/current/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX olires: <https://dantenetwork.it/ontology/olires/current/> PREFIX syntit: <https://dantenetwork.it/ontology/syntit/current/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX lemon: <http://lemon-model.net/lemon#> PREFIX orl: <https://dantenetwork.it/ontology/orl/current/> PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#> prefix tresont: <https://itserr.it/tresont/current/> SELECT (?t_canto as ?Canto) (?t_cantica as ?Cantica) ?sentence ?clfr ?clto ?clafunction ?clocc WHERE { { ?sentence rdf:type syntit:Sentence; ecrm:P148i_is_component_of ?canto. ?seocc olires:occurrenceOf ?sentence; olires:occursInRegion ?frag. ?frag olires:fragmentRegionFrom ?clfr; olires:fragmentRegionTo ?clto. ####aggiungere condizioni sulle clausole } ?canto ecrm:P102_has_title ?t_canto; olires:hasNumber ?num. ?cantica ecrm:P102_has_title ?t_cantica; olires:hasStructuralComponent ?canto. #BIND((str(?clatype1),";", str(?clatype2)) AS ?clatype) #BIND(COALESCE(?posgen,-1) AS ?pos) } ` const sentencetargetstatement_posCoalesce = JSON.parse(`{ "type": "bind", "variable": { "termType": "Variable", "value": "pos" }, "expression": { "type": "operation", "operator": "coalesce", "args": [ { "termType": "Variable", "value": "posgen" }, { "termType": "Literal", "value": "-1", "language": "", "datatype": { "termType": "NamedNode", "value": "http://www.w3.org/2001/XMLSchema#integer" } } ] } }`) const sentencetarget_functionbind = ` { "type": "bind", "variable": { "termType": "Variable", "value": "clafunction" }, "expression": { "type": "operation", "operator": "concat", "args": [] } } ` const sentencetarget_occbind = ` { "type": "bind", "variable": { "termType": "Variable", "value": "clocc" }, "expression": { "type": "operation", "operator": "concat", "args": [] } } ` const sentencetarget_posbind = ` { "type": "bind", "variable": { "termType": "Variable", "value": "pos" }, "expression": { "type": "operation", "operator": "concat", "args": [] } } ` const sentencetarget_syntgroup = `{ "type": "group", "patterns": [ { "type": "bgp", "triples": [ {"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": "https://dantenetwork.it/ontology/syntit/current/hasClauseFunction"}, "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"}} ] } ] } ` 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", "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/olires/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"}}, {"subject": {"termType": "Variable","value": "sentence"}, "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasSyntacticalComponent"}, "object": {"termType": "Variable","value": "clg"}}, {"subject": {"termType": "Variable","value": "cloccte"}, "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occurrenceOf"}, "object": {"termType": "Variable","value": "clg"}}, {"subject": {"termType": "Variable","value": "cloccte"}, "predicate": {"termType": "NamedNode","value": "https://erlangen-crm.org/current/P148_has_component"}, "object": {"termType": "Variable","value": "fa"}} ] } ] } ` const sentencetarget_morphgroup_short = `{"type": "group", "patterns": [{"type": "bgp", "triples": [ {"subject": {"termType": "Variable","value": "fa"}, "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/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": "fa"}, "predicate": {"termType": "NamedNode","value": "https://itserr.it/tresont/current/inSequence"}, "object": {"termType": "Variable","value": "cloccte"}}, {"subject": {"termType": "Variable","value": "fa"}, "predicate": {"termType": "NamedNode","value": "https://itserr.it/tresont/current/hasPosition"}, "object": {"termType": "Variable","value": "seqpos"}}, {"subject": {"termType": "Variable","value": "cloccte"}, "predicate": {"termType": "NamedNode","value": "https://erlangen-crm.org/current/P148_has_component"}, "object": {"termType": "Variable","value": "fa"}}, {"subject": {"termType": "Variable","value": "cloccte"}, "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occurrenceOf"}, "object": {"termType": "Variable","value": "clg"}}, {"subject": {"termType": "Variable","value": "verso"}, "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/hasStructuralComponent"}, "object": {"termType": "Variable","value": "fa"}}, {"subject": {"termType": "Variable","value": "verso"}, "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/hasNumber"}, "object": {"termType": "Variable","value": "nv"}}, {"subject": {"termType": "Variable","value": "reg"}, "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/fragmentRegionFrom"}, "object": {"termType": "Variable","value": "pos"}}, {"subject": {"termType": "Variable","value": "sentence"}, "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/syntit/current/hasSyntacticalComponent"}, "object": {"termType": "Variable","value": "clg"}} ] } ] } ` const sentencetarget_posVariable = `{ "termType": "Variable", "value": "pos" }` const lemma_writtenrepresentation = `{"subject": {"termType": "Variable", "value":"cf"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#writtenRep"}, "object": {"termType": "Variable", "value": "lm"}}` const lemma_canonicalform = `{"subject": {"termType": "Variable", "value":"lent"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#canonicalForm"}, "object": {"termType": "Variable", "value": "cf"}}` const lemma_lexicalform = `{"subject": {"termType": "Variable", "value":"lent"}, "predicate": {"termType":"NamedNode", "value": "http://www.w3.org/ns/lemon/ontolex#lexicalForm"}, "object": {"termType": "Variable", "value": "form"}}` const occurrenceof_form = `{"subject": {"termType": "Variable","value": "fa"}, "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occurrenceOf"}, "object": {"termType": "Variable","value": "form"}}` const clauseocc_hascomponent_formocc = `{"subject": {"termType": "Variable","value": "cloccu"}, "predicate": {"termType": "NamedNode","value": "https://erlangen-crm.org/current/P148_has_component"}, "object": {"termType": "Variable","value": "fa"}}` const occurrenceof_clause = `{"subject": {"termType": "Variable","value": "cloccu"}, "predicate": {"termType": "NamedNode","value": "https://dantenetwork.it/ontology/olires/current/occurrenceOf"}, "object": {"termType": "Variable","value": "cl"}}` //DEFAULT QUERY PER SPARQL EDITOR const defaultEditorQuery = `# ESEMPIO: i periodi della Commedia con una frase con tipo sintattico 'Subordinata Causale' PREFIX ecrm: <https://erlangen-crm.org/current/> PREFIX syntit: <https://dantenetwork.it/ontology/syntit/current/> PREFIX olires: <https://dantenetwork.it/ontology/olires/current/> prefix tresont: <https://itserr.it/tresont/current/> SELECT ?Cantica ?Canto ?Periodo ?FraseSubordinata WHERE { ?cl syntit:hasClauseType syntit:Causale ; ecrm:P190_has_symbolic_content ?FraseSubordinata . ?sentence a syntit:Sentence ; syntit:hasSyntacticalComponent ?cl; ecrm:P190_has_symbolic_content ?Periodo ; ecrm:P148i_is_component_of ?q_canto. ?q_canto ecrm:P102_has_title ?Canto . ?cantica ecrm:P102_has_title ?Cantica; olires:hasStructuralComponent ?q_canto. } order by ?Cantica ?Canto`