query.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. //ATTENZIONE: ALCUNE QUERY HANNO LO STESSO NOME! CAMBIARE I NOMI
  2. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  3. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  4. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  5. PREFIX owl: <http://www.w3.org/2002/07/owl#> \
  6. PREFIX schema: <http://schema.org/> \
  7. PREFIX foaf: <http://xmlns.com/foaf/0.1/> \
  8. PREFIX person: <http://www.w3.org/ns/person#>"
  9. //QUERY DA INTERFACCIA DI RICERCA
  10. //search_graph è il grafo in cui effettuare la ricerca e selezionato attraverso il menu a tendina dell'interfaccia di ricerca
  11. //search_name è la stringa passata dall'input nell'interfaccia di ricerca
  12. queryMMO = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label ?object\
  13. WHERE {GRAPH "+ search_graph +" { ?subject ?property ?object }\
  14. ?subject rdf:type crm:E22_Man-Made_Object ;\
  15. rdfs:label ?label ;\
  16. ?property ?object .\
  17. ?object bif:contains \"\' "+ search_name + " \'\" .\
  18. }"
  19. queryInfObj = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph (SAMPLE(?type) AS ?typeName) ?subject ?label ?object \
  20. WHERE {GRAPH "+ search_graph +" { ?subject ?property ?object }\
  21. ?subject rdf:type crm:E73_Information_Object ;\
  22. rdfs:label ?label ;\
  23. ?property ?object .\
  24. ?object bif:contains \"\' "+ search_name + " \'\" .\
  25. OPTIONAL {?subject crm:P2_has_type ?entity_type . \
  26. ?entity_type rdfs:label ?type .}\
  27. } \
  28. GROUP BY ?subject ?object ?label "+ gg + ""
  29. queryPerson = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label \
  30. WHERE {GRAPH "+ search_graph +" { ?subject rdfs:label ?label ;\
  31. rdf:type crm:E21_Person .\
  32. ?label bif:contains \"\' "+ search_name + " \'\" .}\
  33. }"
  34. queryPlace = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label \
  35. WHERE {GRAPH "+ search_graph +" { ?subject rdfs:label ?label ;\
  36. rdf:type crm:E53_Place .\
  37. ?label bif:contains \"\' "+ search_name + " \'\" .}\
  38. }"
  39. //QUERY SCHEDA LETTERA
  40. //thisUrlParams.link è passato dalla url della pagina ed è il link della risorsa
  41. query1 = prefixes + " SELECT DISTINCT ?mittente ?destinatario ?data_partenza ?data_arrivo ?luogo_partenza ?luogo_arrivo \
  42. WHERE {?subject crm:P128_carries <" + thisUrlParams.link + "> \
  43. GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?subject crm:P25i_moved_by ?mov_ev .} \
  44. ?send rdfs:subClassOf ?mov_ev ; \
  45. rdf:type crm:EL2_Send_Letter ; \
  46. crm:P4_has_time-span ?time_spanA; \
  47. crm:P27_moved_from ?placeA; \
  48. crm:P01_has_domain ?sender . \
  49. \
  50. ?time_spanA rdfs:label ?data_partenza . \
  51. ?placeA rdfs:label ?luogo_partenza . \
  52. ?sender crm:P02_has_range ?mittente . \
  53. \
  54. ?receive rdfs:subClassOf ?mov_ev; \
  55. rdf:type crm:EL3_Receive_Letter ; \
  56. crm:P4_has_time-span ?time_spanB; \
  57. crm:P26_moved_to ?placeB; \
  58. crm:P01_has_domain ?receiver . \
  59. \
  60. ?time_spanB rdfs:label ?data_arrivo . \
  61. ?placeB rdfs:label ?luogo_arrivo . \
  62. ?receiver crm:P02_has_range ?destinatario . \
  63. }"
  64. querySegnatura = prefixes + "SELECT DISTINCT ?segnatura_OVI \
  65. WHERE {?subject crm:P128_carries <" + thisUrlParams.link + ">; \
  66. crm:P1_is_identified_by ?segnatura_ASPO . \
  67. ?segnatura_ASPO crm:P139_has_alternative_form ?segnatura . \
  68. ?segnatura crm:P2_has_type ?tipo_segnatura; \
  69. rdfs:label ?segnatura_OVI . \
  70. ?tipo_segnatura rdfs:label \"Segnatura OVI\"}"
  71. queryAreaLinguistica = prefixes + " SELECT DISTINCT ?lingua ?area_linguistica \
  72. WHERE {<" + thisUrlParams.link + "> crm:P72_has_language ?language . \
  73. ?language crm:P3_has_note ?area ; \
  74. rdfs:label ?lingua . \
  75. ?area rdfs:label ?area_linguistica \
  76. }"
  77. queryDescrizione = prefixes + " SELECT DISTINCT ?descrizione \
  78. WHERE {<" + thisUrlParams.link + "> crm:P3_has_note ?description . \
  79. ?description rdfs:label ?descrizione \
  80. }"
  81. queryTipo = prefixes + " SELECT DISTINCT ?tipologia \
  82. WHERE {<" + thisUrlParams.link + "> crm:P2_has_type ?type . \
  83. ?type rdf:type crm:E55_Type; \
  84. rdfs:label ?tipologia . \
  85. }"
  86. querySiglaOVI = prefixes + " SELECT DISTINCT ?sigla_OVI \
  87. WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?id . \
  88. ?id rdf:type crm:E42_Identifier; \
  89. crm:P2_has_type ?type ; \
  90. rdfs:label ?sigla_OVI . \
  91. ?type rdfs:label 'Sigla OVI'. \
  92. }"
  93. queryTitolo = prefixes + " SELECT DISTINCT ?titolo \
  94. WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?title . \
  95. ?title rdf:type crm:E35_Title; \
  96. rdfs:label ?titolo . \
  97. }"
  98. queryTestoLemmatizzato = prefixes + " SELECT DISTINCT ?testo_lemmatizzato \
  99. WHERE {<" + thisUrlParams.link + "> crm:P190_has_symbolic_content ?testo_lemmatizzato . \
  100. }"
  101. queryEdizione = prefixes + " SELECT DISTINCT ?edizione ?edizione_abbreviata \
  102. WHERE {?edition crm:P70_documents <" + thisUrlParams.link + "> ; \
  103. crm:P1_is_identified_by ?edition_id . \
  104. ?edition_id rdfs:label ?edizione; \
  105. crm:P139_has_alternative_form ?ed_abbr . \
  106. ?ed_abbr rdfs:label ?edizione_abbreviata \
  107. }"
  108. queryRaccolta = prefixes + " SELECT DISTINCT ?raccolta \
  109. WHERE {?racc crm:P148_has_component <" + thisUrlParams.link + "> ; \
  110. crm:P2_has_type ?racc_type ; \
  111. rdfs:label ?raccolta . \
  112. ?racc_type rdfs:label 'Raccolta'. \
  113. }"
  114. queryToponimi = prefixes + "SELECT DISTINCT ?link_toponimo ?toponimo \
  115. WHERE {<" + thisUrlParams.link + "> crm:P67_refers_to ?link_toponimo . \
  116. ?link_toponimo rdfs:label ?toponimo ; \
  117. crm:P2_has_type 'Toponimo' . \
  118. }"
  119. queryAntroponimi = prefixes + "SELECT DISTINCT * \
  120. WHERE {<" + thisUrlParams.link + "> crm:P67_refers_to ?link_antroponimo . \
  121. ?link_antroponimo rdfs:label ?antroponimo; \
  122. crm:P2_has_type 'Antroponimo'}"
  123. //QUERY SCHEDA NLP
  124. //thisUrlParams.link è passato dalla url della pagina ed è il link della risorsa
  125. queryTesto = prefixes + " SELECT DISTINCT ?titolo ?testo WHERE {?subject crm:P128_carries <" + thisUrlParams.link + ">;\
  126. crm:P128_carries ?object .\
  127. ?object rdf:type crm:E33_Linguistic_Object;\
  128. crm:P190_has_symbolic_content ?testo;\
  129. rdfs:label ?titolo .}"
  130. //QUERY SCHEDA LUOGO
  131. //thisUrlParams.link è passato dalla url della pagina ed è il link della risorsa
  132. query = prefixes + " SELECT DISTINCT ?graph ?name_place ?coordinates {\
  133. GRAPH ?graph {<" + thisUrlParams.link + "> crm:P168_place_is_defined_by ?coordinates;\
  134. rdfs:label ?name_place .\
  135. }\
  136. }"
  137. queryRiferimenti = prefixes + " SELECT DISTINCT ?references {\
  138. <" + thisUrlParams.link + "> owl:sameAs ?references\
  139. }"
  140. queryToponimi = prefixes + " SELECT DISTINCT ?toponimi {\
  141. <" + thisUrlParams.link + "> crm:P1_is_identified_by ?uri_toponym .\
  142. ?uri_toponym rdfs:label ?toponimi\
  143. }"
  144. queryRicezione = prefixes + " SELECT DISTINCT ?object ?label {\
  145. <" + thisUrlParams.link + "> owl:sameAs ?place .\
  146. ?event_to crm:P26_moved_to ?place ;\
  147. rdf:type crm:EL3_Receive_Letter ;\
  148. rdfs:subClassOf ?event .\
  149. ?object crm:P25i_moved_by ?event ; \
  150. rdfs:label ?label .\
  151. } "
  152. queryInvio = prefixes + " SELECT DISTINCT ?object ?label {\
  153. <" + thisUrlParams.link + "> owl:sameAs ?place .\
  154. ?event_to crm:P27_moved_from ?place ;\
  155. rdf:type crm:EL2_Send_Letter ;\
  156. rdfs:subClassOf ?event .\
  157. ?object crm:P25i_moved_by ?event ; \
  158. rdfs:label ?label .\
  159. }"
  160. queryCitazione = prefixes + " SELECT DISTINCT ?object ?label\
  161. {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?toponym .\
  162. ?object crm:P67_refers_to ?toponym ;\
  163. rdfs:label ?label\
  164. }"
  165. queryPersone = prefixes + " SELECT DISTINCT ?range ?label \
  166. WHERE{ \
  167. {?place owl:sameAs <" + thisUrlParams.link + "> .\
  168. ?event_to crm:P26_moved_to ?place ;\
  169. rdf:type crm:EL3_Receive_Letter ;\
  170. crm:P01_has_domain ?domain .\
  171. ?domain crm:P02_has_range ?range .\
  172. ?range rdfs:label ?label .\
  173. } UNION {\
  174. ?place owl:sameAs <" + thisUrlParams.link + "> .\
  175. ?event_to crm:P27_moved_from ?place ;\
  176. rdf:type crm:EL2_Send_Letter ;\
  177. crm:P01_has_domain ?domain .\
  178. ?domain crm:P02_has_range ?range .\
  179. ?range rdfs:label ?label .\
  180. }\
  181. }"
  182. queryCount = prefixes + " SELECT ?place ?label COUNT(?label) AS ?Count \
  183. WHERE{ \
  184. ?place_to owl:sameAs <" + thisUrlParams.link + "> . \
  185. ?event_to crm:P26_moved_to ?place_to ; \
  186. rdf:type crm:EL3_Receive_Letter ; \
  187. rdfs:subClassOf ?event . \
  188. ?event_from rdfs:subClassOf ?event ; \
  189. rdf:type crm:EL2_Send_Letter ; \
  190. crm:P27_moved_from ?place . \
  191. ?place rdfs:label ?label \
  192. } \
  193. ORDER BY DESC (?Count)"
  194. queryCount2 = prefixes + " SELECT ?place ?label COUNT(?label) AS ?Count \
  195. WHERE{ \
  196. ?place_from owl:sameAs <" + thisUrlParams.link + "> . \
  197. ?event_from crm:P27_moved_from ?place_from ; \
  198. rdf:type crm:EL2_Send_Letter ; \
  199. rdfs:subClassOf ?event . \
  200. ?event_to rdfs:subClassOf ?event ; \
  201. rdf:type crm:EL2_Send_Letter ; \
  202. crm:P27_moved_from ?place . \
  203. ?place rdfs:label ?label . \
  204. } \
  205. ORDER BY DESC (?Count) "
  206. //QUERY SCHEDA PERSONA
  207. //thisUrlParams.link è passato dalla url della pagina ed è il link della risorsa
  208. query = prefixes + " SELECT DISTINCT ?place ?label ?coordinates \
  209. WHERE { \
  210. {?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
  211. ?event_from crm:P01_has_domain ?pc ; \
  212. rdf:type crm:EL3_Receive_Letter; \
  213. crm:P26_moved_to ?place_from . \
  214. ?place_from rdf:type crm:E53_Place ; \
  215. owl:sameAs ?place . \
  216. ?place rdfs:label ?label ; \
  217. crm:P168_place_is_defined_by ?coordinates . \
  218. } UNION { \
  219. ?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
  220. ?event_from crm:P01_has_domain ?pc ; \
  221. rdf:type crm:EL2_Send_Letter; \
  222. crm:P27_moved_from ?place_from . \
  223. ?place_from rdf:type crm:E53_Place ; \
  224. owl:sameAs ?place . \
  225. ?place rdfs:label ?label ; \
  226. crm:P168_place_is_defined_by ?coordinates . \
  227. } \
  228. }"
  229. queryInfo = prefixes + " SELECT DISTINCT ?graph ?label ?identifier ?name ?givenName ?familyName ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation (group_concat(distinct ?relative1 ;separator=', ') as ?relatives) ?qualification ?group \
  230. WHERE { \
  231. VALUES ?uri {<" + thisUrlParams.link + ">} \
  232. GRAPH ?graph {?uri rdfs:label ?label} \
  233. ?uri foaf:name ?name . \
  234. OPTIONAL {?uri crm:P1_is_identified_by ?id . \
  235. ?id rdfs:label ?identifier } \
  236. OPTIONAL {?uri foaf:givenName ?givenName} \
  237. OPTIONAL {?uri foaf:familyName ?familyName} \
  238. OPTIONAL {?uri foaf:gender ?gender} \
  239. OPTIONAL {?uri person:patronymicName ?patronymic } \
  240. OPTIONAL {?uri schema:hasOccupation ?uriOccupation . \
  241. ?uriOccupation rdf:type schema:Occupation; \
  242. rdfs:label ?occupation } \
  243. OPTIONAL {?uri schema:honorificPrefix ?qualification} \
  244. OPTIONAL {?uri schema:relatedTo ?uriRel1 . \
  245. ?uriRel1 rdfs:label ?relative1} \
  246. OPTIONAL {?uri crm:P100i_died_in ?Death . \
  247. ?Death crm:P4_has_time-span ?Death_TS; \
  248. crm:P7_took_place_at ?Place_D .\
  249. ?Death_TS rdfs:label ?Death_Date . \
  250. ?Place_D rdfs:label ?Death_Place } \
  251. OPTIONAL {?uri crm:P98i_was_born ?Birth . \
  252. ?Birth crm:P4_has_time-span ?Birth_TS; \
  253. crm:P7_took_place_at ?Place_B . \
  254. ?Birth_TS rdfs:label ?Birth_Date . \
  255. ?Place_B rdfs:label ?Birth_Place } \
  256. OPTIONAL {?uri crm:P107i_is_current_or_former_member_of ?uriGroup . \
  257. ?uriGroup rdfs:label ?group } \
  258. } \
  259. GROUP BY ?graph ?label ?identifier ?name ?givenName ?familyName ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation ?qualification ?group "
  260. queryLetters = prefixes + " SELECT DISTINCT ?type ?document_uri ?document_name \
  261. WHERE {?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
  262. ?ev_send crm:P01_has_domain ?pc ; \
  263. rdfs:label ?type ; \
  264. rdfs:subClassOf ?event . \
  265. ?document_uri crm:P25i_moved_by ?event ; \
  266. rdfs:label ?document_name . \
  267. }"
  268. queryNetwork = prefixes + " SELECT DISTINCT ?uri ?label ?uri2 ?label2 \
  269. WHERE { \
  270. {?event rdf:type crm:EL1_Exchange_Letters . \
  271. ?event_to rdfs:subClassOf ?event; \
  272. rdf:type crm:EL2_Send_Letter ; \
  273. crm:P01_has_domain ?pc_to . \
  274. ?pc_to crm:P02_has_range ?uri . \
  275. ?uri rdfs:label ?label . \
  276. ?event_from rdfs:subClassOf ?event; \
  277. rdf:type crm:EL3_Receive_Letter; \
  278. crm:P01_has_domain ?pc_from . \
  279. ?pc_from crm:P02_has_range ?uri2 . \
  280. ?uri2 rdfs:label ?label2 . \
  281. FILTER (?uri = <" + thisUrlParams.link + ">) \
  282. } UNION { \
  283. ?event rdf:type crm:EL1_Exchange_Letters . \
  284. ?event_to rdfs:subClassOf ?event; \
  285. rdf:type crm:EL3_Receive_Letter ; \
  286. crm:P01_has_domain ?pc_from . \
  287. ?pc_from crm:P02_has_range ?uri . \
  288. ?uri rdfs:label ?label . \
  289. ?event_from rdfs:subClassOf ?event; \
  290. rdf:type crm:EL2_Send_Letter; \
  291. crm:P01_has_domain ?pc_to . \
  292. ?pc_to crm:P02_has_range ?uri2 . \
  293. ?uri2 rdfs:label ?label2 . \
  294. FILTER (?uri = <" + thisUrlParams.link + ">) \
  295. } \
  296. } LIMIT 30"
  297. //QUERY SCHEDA OPERA D'ARTE
  298. //thisUrlParams.link è passato dalla url della pagina ed è il link della risorsa
  299. queryInfo = prefixes + " SELECT DISTINCT ?graph ?identifier ?label ?title ?type ?current_owner ?current_location ?subject (group_concat(distinct ?dimension ; separator='<br />') as ?dimensions) (group_concat(distinct ?material ;separator='<br />') as ?materials) ?condition ?note \
  300. WHERE { \
  301. VALUES ?uri {<" + thisUrlParams.link + ">} \
  302. GRAPH ?graph {?uri rdfs:label ?label} \
  303. OPTIONAL {?uri crm:P3_has_note ?note } \
  304. ?uri crm:P128_carries ?Inf_Obj . \
  305. OPTIONAL {?Inf_Obj crm:P1_is_identified_by ?uriTitle . \
  306. ?uriTitle rdf:type crm:E35_Title; \
  307. rdfs:label ?title } \
  308. OPTIONAL {?Inf_Obj crm:P2_has_type ?uriType . \
  309. ?uriType rdfs:label ?type } \
  310. OPTIONAL {?uri crm:P43_has_dimension ?uriDimension . \
  311. ?uriDimension rdfs:label ?dimension } \
  312. OPTIONAL {?uri crm:P1_is_identified_by ?uriIdentifier . \
  313. ?uriIdentifier rdfs:label ?identifier } \
  314. OPTIONAL {?uri crm:P45_consists_of ?uriMaterial . \
  315. ?uriMaterial rdfs:label ?material } \
  316. OPTIONAL {?uri crm:P44_has_condition ?uriCondition . \
  317. ?uriCondition crm:P2_has_type ?condition} \
  318. OPTIONAL {?uri crm:P54_has_current_permanent_location ?current_location } \
  319. OPTIONAL {?uri crm:P62_depicts ?uriSubject . \
  320. ?uriSubject rdfs:label ?subject; \
  321. crm:P2_has_type 'Identificazione Iconografica' .} \
  322. OPTIONAL {?uri crm:P52_has_current_owner ?uriOwner . \
  323. ?uriOwner rdfs:label ?current_owner } \
  324. }"
  325. queryProduction = prefixes + " SELECT DISTINCT (GROUP_CONCAT(DISTINCT CONCAT(?uriPerson, '; ', ?person, '; ', ?role) ; SEPARATOR = '<br />') AS ?Partecipants) (group_concat(distinct ?time_span ;separator='-') as ?time) (group_concat(distinct ?technique ;separator='<br />') as ?techniques) \
  326. WHERE { \
  327. VALUES ?uri {<" + thisUrlParams.link + ">} \
  328. ?uri crm:P128_carries ?Information_Object . \
  329. ?Information_Object crm:P108i_was_produced_by ?Production . \
  330. OPTIONAL {?Production crm:P4_has_time-span ?uriTS ; \
  331. crm:P32_used_general_technique ?uriTecne . \
  332. ?uriTS rdfs:label ?time_span . \
  333. ?uriTecne rdfs:label ?technique} \
  334. OPTIONAL {?pc crm:P01_has_domain ?Production ; \
  335. crm:P02_has_range ?uriPerson ; \
  336. crm:P14.1_in_the_role_of ?uriRole . \
  337. ?uriPerson rdfs:label ?person . \
  338. ?uriRole rdfs:label ?role} \
  339. }"