lettera_query.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // Raccatto i parametri dall'URL -- mi aspetto un parametro di nome 'link'!
  2. thisUrlParams = {};
  3. window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  4. thisUrlParams[key] = value;
  5. });
  6. console.log('URL get params: ', thisUrlParams);
  7. // Funzioni per eseguire le queries
  8. function prepareQueryURL(query){
  9. sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/';
  10. sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?';
  11. return sparqlEndpoint + sparqlUrlParams;
  12. }
  13. function doJsonQuery(query){
  14. queryURL = prepareQueryURL(query);
  15. response = $.ajax({//OGGETTO
  16. url: queryURL,
  17. dataType: "json",
  18. success: function (data){},
  19. error: function (e) {}
  20. });
  21. return response;
  22. }
  23. function loadPageNLP()
  24. {
  25. window.location="nlp.html?link=" + thisUrlParams.link;
  26. }
  27. // Funzioni per raccattare + stringhificare l'output
  28. queryStringOutput = "";
  29. function stringifyResponse(val){
  30. resultArray = val['results']['bindings'];
  31. out = "";
  32. for(i = 0; i < resultArray.length; i++){
  33. out = out + JSON.stringify(resultArray[i])
  34. }
  35. queryStringOutput = (queryStringOutput + out).replace("}{",",");
  36. }
  37. ////////////////////
  38. // TESTI DELLE QUERY
  39. ////////////////////
  40. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  41. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  42. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  43. PREFIX dat: <http://datini.archiviodistato.prato.it/la-ricerca/scheda/> \
  44. PREFIX mpp: <http://palazzopretorio.comune.prato.it/it/le-opere/alcuni-capolavori/> \
  45. PREFIX aut: <http://palazzopretorio.comune.prato.it/it/opere/autori/>"
  46. query1 = prefixes + " SELECT DISTINCT ?mittente ?destinatario ?data_partenza ?data_arrivo ?luogo_partenza ?luogo_arrivo \
  47. WHERE {?subject crm:P128_carries <" + thisUrlParams.link + "> \
  48. GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini/ex> {?subject crm:P25i_moved_by ?mov_ev .} \
  49. ?send rdfs:subClassOf ?mov_ev ; \
  50. rdf:type crm:EL2_Send_Letter ; \
  51. crm:P4_has_time-span ?time_spanA; \
  52. crm:P27_moved_from ?placeA; \
  53. crm:P01_has_domain ?sender . \
  54. \
  55. ?time_spanA rdfs:label ?data_partenza . \
  56. ?placeA rdfs:label ?luogo_partenza . \
  57. ?sender crm:P02_has_range ?mittente . \
  58. \
  59. ?receive rdfs:subClassOf ?mov_ev; \
  60. rdf:type crm:EL3_Receive_Letter ; \
  61. crm:P4_has_time-span ?time_spanB; \
  62. crm:P26_moved_to ?placeB; \
  63. crm:P01_has_domain ?receiver . \
  64. \
  65. ?time_spanB rdfs:label ?data_arrivo . \
  66. ?placeB rdfs:label ?luogo_arrivo . \
  67. ?receiver crm:P02_has_range ?destinatario . \
  68. }"
  69. querySegnatura = prefixes + "SELECT DISTINCT ?segnatura_OVI \
  70. WHERE {?subject crm:P128_carries <" + thisUrlParams.link + ">; \
  71. crm:P1_is_identified_by ?segnatura_ASPO . \
  72. ?segnatura_ASPO crm:P139_has_alternative_form ?segnatura . \
  73. ?segnatura crm:P2_has_type ?tipo_segnatura; \
  74. rdfs:label ?segnatura_OVI . \
  75. ?tipo_segnatura rdfs:label \"Segnatura OVI\"}"
  76. queryAreaLinguistica = prefixes + " SELECT DISTINCT ?lingua ?area_linguistica \
  77. WHERE {<" + thisUrlParams.link + "> crm:P72_has_language ?language . \
  78. ?language crm:P3_has_note ?area ; \
  79. rdfs:label ?lingua . \
  80. ?area rdfs:label ?area_linguistica \
  81. }"
  82. queryDescrizione = prefixes + " SELECT DISTINCT ?descrizione \
  83. WHERE {<" + thisUrlParams.link + "> crm:P3_has_note ?description . \
  84. ?description rdfs:label ?descrizione \
  85. }"
  86. queryTipo = prefixes + " SELECT DISTINCT ?tipologia \
  87. WHERE {<" + thisUrlParams.link + "> crm:P2_has_type ?type . \
  88. ?type rdf:type crm:E55_Type; \
  89. rdfs:label ?tipologia . \
  90. }"
  91. querySiglaOVI = prefixes + " SELECT DISTINCT ?sigla_OVI \
  92. WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?id . \
  93. ?id rdf:type crm:E42_Identifier; \
  94. crm:P2_has_type ?type ; \
  95. rdfs:label ?sigla_OVI . \
  96. ?type rdfs:label 'Sigla OVI'. \
  97. }"
  98. queryTitolo = prefixes + " SELECT DISTINCT ?titolo \
  99. WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?title . \
  100. ?title rdf:type crm:E35_Title; \
  101. rdfs:label ?titolo . \
  102. }"
  103. queryTestoLemmatizzato = prefixes + " SELECT DISTINCT ?testo_lemmatizzato \
  104. WHERE {<" + thisUrlParams.link + "> crm:P190_has_symbolic_content ?testo_lemmatizzato . \
  105. }"
  106. queryEdizione = prefixes + " SELECT DISTINCT ?edizione ?edizione_abbreviata \
  107. WHERE {?edition crm:P70_documents <" + thisUrlParams.link + "> ; \
  108. crm:P1_is_identified_by ?edition_id . \
  109. ?edition_id rdfs:label ?edizione; \
  110. crm:P139_has_alternative_form ?ed_abbr . \
  111. ?ed_abbr rdfs:label ?edizione_abbreviata \
  112. }"
  113. queryRaccolta = prefixes + " SELECT DISTINCT ?raccolta \
  114. WHERE {?racc crm:P148_has_component <" + thisUrlParams.link + "> ; \
  115. crm:P2_has_type ?racc_type ; \
  116. rdfs:label ?raccolta . \
  117. ?racc_type rdfs:label 'Raccolta'. \
  118. }"