실습 SQARPLE

workshop
김사현 (토론 | 기여)님의 2019년 8월 8일 (목) 13:43 판
둘러보기로 가기 검색하러 가기

국가서지 LOD, 국립중앙도서관 http://lod.nl.go.kr/sparql

prefix dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX nlon: <http://lod.nl.go.kr/ontology/> 

SELECT * 

WHERE { 
<http://lod.nl.go.kr/resource/KSH00246771> nlon:isSubjectOf ?book.
?book rdf:type nlon:Book.
?book dcterms:title ?bookname.
?book dc:creator ?creator.
?book nlon:remainderOfTitle ?subtitle.
}

limit 100

한국사LOD - http://lod.koreanhistory.or.kr/lodSparqlEndPoint.do

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX hlod: http://lod.koreanhistory.or.kr/

select * 

where {
hlod:인명_정약용 hlod:hasCareerInfo ?careerinfo.
?careerinfo hlod:careerName ?career.
?careerinfo hlod:hasStartDate ?startDate.
?careerinfo hlod:hasEndDate ?endDate.
?careerinfo hlod:hasDynasty ?dynasty.

}

스마트관광정보LOD - http://data.visitkorea.or.kr/sparql

  • 수원에 있는 문화유적지와 위경도 검색해보기
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX kto: <http://data.visitkorea.or.kr/ontology/>
PREFIX ktop: <http://data.visitkorea.or.kr/property/>
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>

SELECT ?HistoricalPlace ?label ?address ?lat ?long
WHERE {
 ?HistoricalPlace rdf:type kto:HistoricalPlace.
 ?HistoricalPlace ktop:location ?location.
 ?location skos:broader <http://data.visitkorea.or.kr/resource/CATEGORY:311300>.
 
  ?HistoricalPlace ktop:address ?address.
  ?HistoricalPlace rdfs:label ?label.
  
   ?HistoricalPlace wgs:lat ?lat.
   ?HistoricalPlace wgs:long ?long.                      
} 	


owl:sameAs와 SERVICE

  • 서로 다른 LOD 서비스에서 동일한 개체들이 owl:sameAs로 연결되어 있으면 SERVICE 기능을 이용해 그 개체에 대한 정보를 통합 검색할 수 있다.
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>

SELECT ?person  ?relatedData1 ?relatedData2

WHERE { 
?person edm:isRelatedTo ?relatedData1.
?person owl:sameAs ?samePerson
 SERVICE <http://anotherLOD/sparql> 
               {?sameperson edm:isRelatedTo ?relatedData2.} 
}