// Recupero i parametri dall'URL -- mi aspetto un parametro di nome 'link'! thisUrlParams = {}; window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { thisUrlParams[key] = value; }); console.log('URL get params: ', thisUrlParams); // Funzioni per eseguire le queries function prepareQueryURL(query){ sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/'; sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?'; return sparqlEndpoint + sparqlUrlParams; } // Esegue una query sull'endpoint SPARQL il cui testo completo deve essere fornito nel parametro-stringa 'query' // Restituisce una lista di oggetti json nel formato di Virtuoso // Il parametro opzionale 'isUnique', se messo a 'true' controlla che ci sia un unico risultato (un array di // lunghezza 1) e se non è così restituisce un errore. async function doJsonQuery(query, isUnique = false){ queryURL = prepareQueryURL(query); response = await $.ajax({//OGGETTO url: queryURL, dataType: "json", success: function (data){}, error: function (e) { console.log("Exception in query:", e); } }); let out = response['results']['bindings']; if(!isUnique) return out; if(!out.length) throw "ERROR: Letter not found"; if(out.length>1) throw "ERROR: ambiguity in search -- multiple letters matching search parameters"; return out[0]; } // Nuova funzione per l'NLP function loadPageNLP() { window.location="nlp.html?link=" + thisUrlParams.link; } // Nuova funzione per Button LOD function loadPageLOD() { window.location="http://dev.restore.ovi.cnr.it/lodlive/?" + thisUrlParams.link; } //////////////////// // TESTI DELLE QUERY //////////////////// prefixes = "PREFIX rdfs: \ PREFIX rdf: \ PREFIX crm: \ PREFIX dat: \ PREFIX mpp: \ PREFIX aut: " query1 = prefixes + " SELECT DISTINCT ?subject ?mittente ?destinatario ?data_partenza ?data_arrivo ?uriLuogoPartenza ?luogo_partenza ?uriLuogoArrivo ?luogo_arrivo \ WHERE {?subject crm:P128_carries <" + thisUrlParams.link + "> \ GRAPH {?subject crm:P25i_moved_by ?mov_ev .} \ ?send rdfs:subClassOf ?mov_ev ; \ rdf:type crm:EL2_Send_Letter . \ OPTIONAL {?send crm:P4_has_time-span ?time_spanA . \ ?time_spanA rdfs:label ?data_partenza . } \ OPTIONAL {?send crm:P27_moved_from ?uriLuogoPartenza . \ ?uriLuogoPartenza rdfs:label ?luogo_partenza . } \ OPTIONAL {?send crm:P01_has_domain ?uriMittente . \ ?uriMittente crm:P02_has_range ?mittente . } \ \ ?receive rdfs:subClassOf ?mov_ev; \ rdf:type crm:EL3_Receive_Letter . \ OPTIONAL {?receive crm:P4_has_time-span ?time_spanB . \ ?time_spanB rdfs:label ?data_arrivo . } \ OPTIONAL {?receive crm:P26_moved_to ?uriLuogoArrivo . \ ?uriLuogoArrivo rdfs:label ?luogo_arrivo . } \ OPTIONAL {?receive crm:P01_has_domain ?receiver . \ ?receiver crm:P02_has_range ?destinatario . } \ } LIMIT 1" query2 = prefixes + " SELECT DISTINCT ?uriSender ?mittente ?uriReceiver ?destinatario ?timeSpanSend ?timeSpanReceive ?placeSend ?placeReceive ?identifier ?material ?dimension ?currentLocation \ WHERE {?subject crm:P128_carries <" + thisUrlParams.link + "> . \ GRAPH {?subject crm:P25i_moved_by ?mov_ev .} \ ?send rdfs:subClassOf ?mov_ev ; \ rdf:type crm:EL2_Send_Letter . \ ?receive rdfs:subClassOf ?mov_ev ; \ rdf:type crm:EL3_Receive_Letter . \ \ OPTIONAL {?subject crm:P54_has_current_permanent_location ?currentLocation . } \ OPTIONAL {?subject crm:P45_consist_of ?uriMaterial . \ ?uriMaterial rdfs:label ?material . } \ OPTIONAL {?subject crm:P43_has_dimension ?uriDimension . \ ?uriDimension rdfs:label ?dimension . } \ OPTIONAL {?subject crm:P1_is_identified_by ?uriIdentifier . \ ?uriIdentifier rdfs:label ?identifier . \ ?identifier bif:contains 'Segnatura'} \ \ OPTIONAL {?send crm:P4_has_time-span ?time_spanS . \ ?time_spanS rdfs:label ?timeSpanSend } \ OPTIONAL {?receive crm:P4_has_time-span ?time_spanR . \ ?time_spanR rdfs:label ?timeSpanReceive } \ \ OPTIONAL {?send crm:P27_moved_from ?placeS . \ ?placeS rdfs:label ?placeSend } \ OPTIONAL {?receive crm:P26_moved_to ?placeR . \ ?placeR rdfs:label ?placeReceive } \ \ OPTIONAL {?send crm:P01_has_domain ?pcS . \ ?pcS crm:P02_has_range ?uriSender . \ ?uriSender rdfs:label ?mittente } \ \ OPTIONAL {?receive crm:P01_has_domain ?pcR . \ ?pcR crm:P02_has_range ?uriReceiver . \ ?uriReceiver rdfs:label ?destinatario } \ } LIMIT 1" querySegnatura = prefixes + "SELECT DISTINCT ?segnatura_OVI \ WHERE {?subject crm:P128_carries <" + thisUrlParams.link + ">; \ crm:P1_is_identified_by ?segnatura_ASPO . \ ?segnatura_ASPO crm:P139_has_alternative_form ?segnatura . \ ?segnatura crm:P2_has_type ?tipo_segnatura ; \ rdfs:label ?segnatura_OVI . \ ?tipo_segnatura rdfs:label \"Segnatura OVI\"} LIMIT 1" queryAreaLinguistica = prefixes + " SELECT DISTINCT ?lingua ?area_linguistica \ WHERE {<" + thisUrlParams.link + "> crm:P72_has_language ?language . \ ?language crm:P3_has_note ?area ; \ rdfs:label ?lingua . \ ?area rdfs:label ?area_linguistica \ } LIMIT 1" queryDescrizione = prefixes + " SELECT DISTINCT ?descrizione \ WHERE {<" + thisUrlParams.link + "> crm:P3_has_note ?description . \ ?description rdfs:label ?descrizione \ } LIMIT 1" queryTipo = prefixes + " SELECT DISTINCT ?tipologia \ WHERE {<" + thisUrlParams.link + "> crm:P2_has_type ?type . \ ?type rdf:type crm:E55_Type; \ rdfs:label ?tipologia . \ } LIMIT 1" querySiglaOVI = prefixes + " SELECT DISTINCT ?sigla_OVI \ WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?id . \ ?id rdf:type crm:E42_Identifier; \ crm:P2_has_type ?type ; \ rdfs:label ?sigla_OVI . \ ?type rdfs:label 'Sigla OVI'. \ } LIMIT 1" queryTitolo = prefixes + " SELECT DISTINCT ?titolo \ WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?uri_title . \ ?uri_title rdf:type crm:E35_Title ; \ rdfs:label ?titolo . \ } LIMIT 1" queryTestoLemmatizzato = prefixes + " SELECT DISTINCT ?testo_lemmatizzato \ WHERE {<" + thisUrlParams.link + "> crm:P190_has_symbolic_content ?testo_lemmatizzato . \ } LIMIT 1" queryEdizione = prefixes + " SELECT DISTINCT ?edizione ?edizione_abbreviata \ WHERE {?edition crm:P70_documents <" + thisUrlParams.link + "> ; \ crm:P1_is_identified_by ?edition_id . \ ?edition_id rdfs:label ?edizione; \ crm:P139_has_alternative_form ?ed_abbr . \ ?ed_abbr rdfs:label ?edizione_abbreviata \ } LIMIT 1" queryRaccolta = prefixes + " SELECT DISTINCT ?raccolta \ WHERE {?racc crm:P148_has_component <" + thisUrlParams.link + "> ; \ crm:P2_has_type ?racc_type ; \ rdfs:label ?raccolta . \ ?racc_type rdfs:label 'Raccolta'. \ } LIMIT 1" queryToponimi = prefixes + "SELECT DISTINCT ?uri_lemma ?lemma ?uri_place \ WHERE {<" + thisUrlParams.link + "> crm:P67_refers_to ?uri_lemma . \ ?uri_lemma rdfs:label ?lemma ; \ crm:P2_has_type 'Toponimo' . \ OPTIONAL {?uri_place crm:P1_is_identified_by ?uri_lemma ; \ crm:P168_place_is_defined_by ?coords . \ } \ }" queryAntroponimi = prefixes + "SELECT DISTINCT ?uri_lemma ?lemma \ WHERE {<" + thisUrlParams.link + "> crm:P67_refers_to ?uri_lemma . \ ?uri_lemma rdfs:label ?lemma; \ crm:P2_has_type 'Antroponimo'}" queryLemmi = prefixes + " SELECT DISTINCT ?uri_lemma ?lemma ?tipo ?pos ?uri_iperlemma ?iperlemma \ WHERE {<" + thisUrlParams.link + "> crm:P67_refers_to ?uri_thing . \ ?uri_thing crm:P128_carries ?uri_lemma . \ ?uri_lemma rdfs:label ?lemma ; \ crm:P2_has_type ?uri_pos . \ ?uri_pos rdfs:label ?pos . \ OPTIONAL {?uri_thing crm:P2_has_type ?uri_type . \ ?uri_type rdfs:label ?tipo .} \ OPTIONAL {?uri_lemma rdfs:subClassOf ?uri_iperlemma . \ ?uri_iperlemma rdfs:label ?iperlemma .} \ }"