제도와 인사의 관계성 데이터 아카이브에 대한 SPARQL 활용 예시
// 모든 조직의 이름을 알고 싶다.
// 조직(학교) 이름을 모두 출력하라.
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select *
where {
?schooltemp rdf:type schoolsys:Group .
?schooltemp rdfs:label ?schoolname
}
// 조직의 한글이름을 역순 정렬로 보고 싶다.
// 한글로 된 조직(학교) 이름을 모두 순차정렬로 출력하라.
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select *
where {
?schooltemp rdf:type schoolsys:Group .
?schooltemp rdfs:label ?schoolname
FILTER(LANGMATCHES(LANG(?schoolname), "ko-hangul"))
} order by ?schoolname
// 조직의 한자이름을 역순 정렬로 보고 싶다.
// 한자로 된 조직(학교) 이름을 모두 역순정렬로 출력하라.
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select *
where {
?schooltemp rdf:type schoolsys:Group .
?schooltemp rdfs:label ?schoolname
FILTER(LANGMATCHES(LANG(?schoolname), "ko-hanza"))
} order by desc(?schoolname)
// "영암"에 관련된 조직의 이름을 알고 싶다.
// 한글로 된 "영암"이 포함된 조직 이름을 모두 출력하라.
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select *
where {
?schooltemp rdf:type schoolsys:Group .
?schooltemp rdfs:label ?schoolname
FILTER regex( str(?schoolname),"영암" )
FILTER(LANGMATCHES(LANG(?schoolname), "ko-hangul"))
}
// 보통학교의 목록이 보고 싶다.
// 분류가 보통학교인 학교의 한글 이름을 출력하라.
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?schoolname ?subjectname
where {
?schooltemp rdf:type schoolsys:Group .
?schooltemp rdfs:label ?schoolname .
FILTER(LANGMATCHES(LANG(?schoolname), "ko-hangul"))
?schooltemp rdf:subject ?subjecttemp .
?subjecttemp rdfs:label ?subjectname .
FILTER regex( str(?subjectname),"보통학교" )
}
// 조직의 이름을 "한글이름(한자이름)"의 형식으로 보고 싶다.
// 조직의 한글이름과 한자이름을 합쳐서 "한글이름(한자이름)"의 형식으로 출력하라.
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?schoolnamehan ?schoolnamehanza ?schoolname
where {
?schooltemp rdf:type schoolsys:Group .
?schooltemp rdfs:label ?schoolnamehan .
FILTER(LANGMATCHES(LANG(?schoolnamehan ), "ko-hangul"))
?schooltemp rdfs:label ?schoolnamehanza .
FILTER(LANGMATCHES(LANG(?schoolnamehanza ), "ko-hanza"))
BIND (CONCAT(?schoolnamehan , "(", ?schoolnamehanza, ")" ) AS ?schoolname)
}
// 각각의 기관은 몇 개나 있는가?
// 기관 분류별 개수 통계 출력
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select (count(distinct *) AS ?CNT) ?subjectname
where {
?schooltemp rdf:type schoolsys:Group .
?schooltemp rdfs:label ?schoolname .
FILTER(LANGMATCHES(LANG(?schoolname), "ko-hangul"))
?schooltemp rdf:subject ?subjecttemp .
?subjecttemp rdfs:label ?subjectname .
} group by ?subjectname
// 교원의 보직 이동은 어떤 학교에서 어떤 학교로 이루어졌는가?
// 보직이동에 관하여 "이전조직", "이후조직", "시간정보", "출처정보"를 출력하라
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?preschool ?postschool ?time ?webre
where {
?eventtemp rdf:type kyujanggak:Event.
?eventtemp schoolsys:hasEventPreObject ?preobjecttemp .
?preobjecttemp rdf:type schoolsys:Group .
?preobjecttemp rdfs:label ?preschool.
FILTER(LANGMATCHES(LANG(?preschool), "ko-hangul"))
?eventtemp schoolsys:hasEventPostObject ?postobjecttemp .
?postobjecttemp rdf:type schoolsys:Group .
?postobjecttemp rdfs:label ?postschool.
FILTER(LANGMATCHES(LANG(?postschool), "ko-hangul"))
?eventtemp schoolsys:hasEventType <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#C_PM_0001> .
?eventtemp schoolsys:hasTimeValue ?time .
?eventtemp schoolsys:hasWebResource ?webre .
}
// 1902년 1월 21일 이후의 교원의 보직 이동은 어떤 학교에서 어떤 학교로 이루어졌는가?
// 1902년 1월 21일 이후의 보직이동에 관하여 "이전조직", "이후조직", "시간정보"를 출력하라
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?preschool ?postschool ?time
where {
?eventtemp rdf:type kyujanggak:Event.
?eventtemp schoolsys:hasEventPreObject ?preobjecttemp .
?preobjecttemp rdf:type schoolsys:Group .
?preobjecttemp rdfs:label ?preschool.
FILTER(LANGMATCHES(LANG(?preschool), "ko-hangul"))
?eventtemp schoolsys:hasEventPostObject ?postobjecttemp .
?postobjecttemp rdf:type schoolsys:Group .
?postobjecttemp rdfs:label ?postschool.
FILTER(LANGMATCHES(LANG(?postschool), "ko-hangul"))
?eventtemp schoolsys:hasEventType <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#C_PM_0001> .
?eventtemp schoolsys:hasTimeValue ?time .
FILTER ( ?time > "1902-01-21T09:00:00+09:00"^^xsd:dateTime )
}
// 1902년 1월 21일 이후부터 1905년 10월 17일사이에 교원의 보직 이동은 어떤 학교에서 어떤 학교로 이루어졌는가?
// 1902년 1월 21일 이후부터 1905년 10월 17일사이의 보직이동에 관하여 "이전조직", "이후조직", "시간정보"를 출력하라
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?preschool ?postschool ?time
where {
?eventtemp rdf:type kyujanggak:Event.
?eventtemp schoolsys:hasEventPreObject ?preobjecttemp .
?preobjecttemp rdf:type schoolsys:Group .
?preobjecttemp rdfs:label ?preschool.
FILTER(LANGMATCHES(LANG(?preschool), "ko-hangul"))
?eventtemp schoolsys:hasEventPostObject ?postobjecttemp .
?postobjecttemp rdf:type schoolsys:Group .
?postobjecttemp rdfs:label ?postschool.
FILTER(LANGMATCHES(LANG(?postschool), "ko-hangul"))
?eventtemp schoolsys:hasEventType <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#C_PM_0001> .
?eventtemp schoolsys:hasTimeValue ?time .
FILTER ( ?time > "1902-01-21T09:00:00+09:00"^^xsd:dateTime )
FILTER ( ?time < "1905-10-17T09:00:00+09:00"^^xsd:dateTime )
}
// 의원면직자의 숫자는 시기별로 어떻게 변화하였는가?
// 시기별 의원면직자수 통계표를 추출하라.
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select (count(distinct *) AS ?CNT) ?time
where {
?eventtemp rdf:type kyujanggak:Event.
?eventtemp schoolsys:hasEventObject ?objecttemp .
?objecttemp rdf:type schoolsys:Person .
?objecttemp rdfs:label ?personobj.
FILTER(LANGMATCHES(LANG(?personobj), "ko-hanza"))
?eventtemp schoolsys:hasEventType <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#C_PM_0006> .
?eventtemp schoolsys:hasTimeValue ?time
} group by ?time
// 관립교통보통학교는 현재 서울시의 어떤 초등학교인가?
// 서울시LOD와 연계하여 관립교동보통학교에서 승계된 현재 학교의 한글, 영어, 중국어 이름을 출력하라.
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX seoul: <http://lod.seoul.go.kr/ontology/>
SELECT ?seoulschoolname
WHERE { <http://dh.aks.ac.kr/ddokbaro#G_school_000024> schoolsys:hasCurrentSchool ?nametemp
SERVICE <http://lod.seoul.go.kr/sparql/> {
?nametemp rdfs:label ?seoulschoolname
}
}
// 구한말 학교의 위치는 어디인가?
// 구한말 학교의 시기별 경위도 좌표를 출력하시오.
PREFIX schoolsys: <http://dh.aks.ac.kr/ontologies/personnelmatters/schoolsystem#>
PREFIX historygokr: <http://dh.aks.ac.kr/ontologies/personnelmatters/historygokr#>
PREFIX kyujanggak: <http://dh.aks.ac.kr/ontologies/personnelmatters/kyujanggak#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX seoul: <http://lod.seoul.go.kr/ontology/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?schoollabel ?lat ?long ?time
WHERE {
?eventtemp rdf:type schoolsys:Event .
?eventtemp schoolsys:hasEventType ?ettemp .
?ettemp rdfs:label ?ettempname .
FILTER regex( str(?ettempname ),"경위도좌표" )
?eventtemp schoolsys:hasEventObject ?schooltemp .
?schooltemp rdf:type schoolsys:Group .
?schooltemp rdfs:label ?schoollabel .
FILTER(LANGMATCHES(LANG(?schoollabel), "ko-hangul"))
?eventtemp geo:lat ?lat .
?eventtemp geo:long ?long .
?eventtemp schoolsys:hasTimeValue ?time
}