Linked Data 用のRDF表現のためにWhen::Parts::Resourceに用意した主なメソッドは下記の通りです。
単独のインスタンスの情報(原則としてそのインスタンスを主語とするトリプル)を JSON-LD 形式に対応する Hash にまとめて返します。
扱うデータ形式は Hash(とArray)のため、Linked Data 系の gem には依存しません。
複数のインスタンスの情報を JSON-LD 形式に対応する Hash にまとめて返します。 複数のインスタンスは JSON-LD の '@graph' を使ってまとめます。
インスタンスメソッドでは、そのインスタンスが包含する(例えば「明治5.12」は「明治5.12.01」と「明治5.12.02」を包含する)インスタンスも対象にできます。
クラスメソッドでは、対象とするインスタンスを Range や Array でまとめて指定します。
扱うデータ形式は Hash(とArray)のため、Linked Data 系の gem には依存しません。
v0.4.6 では yard がメソッドヘッダのparseに失敗したため、When::Parts::Resource.rdf_graph の API が APIドキュメントにありません。 当面は、When::TM::CalDate#rdf_graphのAPI, When::TM::CalDate#to_jsonld_hashのAPIおよびGitHubのソースの当該部分で API をご確認ください。
複数のインスタンスの情報を指定されたRDF表現(RDF/XML, JSON-LD, Turtle, N-Triples, Notation3)で返します。
インスタンスメソッドでは、そのインスタンスが包含するインスタンスも対象にできます。
クラスメソッドでは、あらかじめ rdf_graphメソッドなどで JSON-LD 形式に対応する Hash にした情報を入力とします。
返そうとするRDF表現に対応した gem を install しておく必要があります。
when_exe と pp を require しておきます。
require 'pp' require 'when_exe'
pp When.when?('明治5.12').to_jsonld_hash #=> # {"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"=> # {"@id"=>"http://hosi.org/ts/When/TM/CalDate"}, # "@id"=>"http://hosi.org/tp/明治05(1872)-12-", # "http://hosi.org/ts#sdn"=>2405158, # "http://hosi.org/ts#frame"=> # {"@id"=>"http://hosi.org/When/CalendarTypes/Japanese"}, # "http://hosi.org/ts#calendarEra"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治"}, # "http://hosi.org/ts#coordinate"=>"12", # "http://hosi.org/ts#ruler"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇"}, # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::月名"=> # {"@id"=>"http://hosi.org/When/BasicTypes/M17n/Japanese::Month::十二月"}, # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::廿八宿"=> # {"@id"=>"http://hosi.org/When/Coordinates/Common::宿::危宿"}, # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::月建"=> # {"@id"=>"http://hosi.org/When/Coordinates/Common::干支::癸丑"}, # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::天道"=>"西行", # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::天徳"=>"庚", # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::月煞"=>"辰", # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::用時"=>"乙丁辛亥", # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::月徳"=>"庚", # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::月徳合"=>"乙", # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::月空"=>"甲", # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::三鏡"=>"甲乙丁庚辛癸", # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::土府"=>"子", # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::土公"=>"庭", # "http://hosi.org/When/CalendarNote/Japanese/Notes::月::大小"=>"改(2)"}
:context=>true と設定すると、動的に namespace を抽出して、prefix を付けます。
'@context'=>{} と設定すると、抽出結果を出力の '@context' に書き出します。
pp When.when?('明治5.12').to_jsonld_hash({'@context'=>{}, :context=>true}) #=> # {"@context"=> # {"rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#", # "ts"=>"http://hosi.org/ts#", # "Month"=>"http://hosi.org/When/BasicTypes/M17n/Japanese::Month::", # "MonthNote"=>"http://hosi.org/When/CalendarNote/Japanese/Notes::月::", # "LunarMansion"=>"http://hosi.org/When/Coordinates/Common::宿::", # "Stem-Branch"=>"http://hosi.org/When/Coordinates/Common::干支::"}, # "rdf:type"=>{"@id"=>"http://hosi.org/ts/When/TM/CalDate"}, # "@id"=>"http://hosi.org/tp/明治05(1872)-12-", # "ts:sdn"=>2405158, # "ts:frame"=>{"@id"=>"http://hosi.org/When/CalendarTypes/Japanese"}, # "ts:calendarEra"=>{"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治"}, # "ts:coordinate"=>"12", # "ts:ruler"=>{"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇"}, # "MonthNote:月名"=>{"@id"=>"Month:十二月"}, # "MonthNote:廿八宿"=>{"@id"=>"LunarMansion:危宿"}, # "MonthNote:月建"=>{"@id"=>"Stem-Branch:癸丑"}, # "MonthNote:天道"=>"西行", # "MonthNote:天徳"=>"庚", # "MonthNote:月煞"=>"辰", # "MonthNote:用時"=>"乙丁辛亥", # "MonthNote:月徳"=>"庚", # "MonthNote:月徳合"=>"乙", # "MonthNote:月空"=>"甲", # "MonthNote:三鏡"=>"甲乙丁庚辛癸", # "MonthNote:土府"=>"子", # "MonthNote:土公"=>"庭", # "MonthNote:大小"=>"改(2)"}
:include=>true と設定すると、自身が包含するインスタンスの情報も返します。
:included=>true と設定すると、自身を包含するインスタンスの参照(rdfs:member)も返します。
pp When.when?('明治5.12').rdf_graph({'@context'=>{}, :context=>true, :included=>true, :include=>true}) #=> # {"@context"=> # {"xsd"=>"http://www.w3.org/2001/XMLSchema", # "rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#", # "rdfs"=>"http://www.w3.org/2000/01/rdf-schema#", # "owl"=>"http://www.w3.org/2002/07/owl#", # "dc"=>"http://purl.org/dc/elements/1.1/", # "dcq"=>"http://purl.org/dc/terms/", # "dct"=>"http://purl.org/dc/dcmitype/", # "ts"=>"http://hosi.org/ts#", # "Month"=>"http://hosi.org/When/BasicTypes/M17n/Japanese::Month::", # "MonthNote"=>"http://hosi.org/When/CalendarNote/Japanese/Notes::月::", # "LunarMansion"=>"http://hosi.org/When/Coordinates/Common::宿::", # "Stem-Branch"=>"http://hosi.org/When/Coordinates/Common::干支::", # "DayNote"=>"http://hosi.org/When/CalendarNote/Japanese/Notes::日::", # "Week"=>"http://hosi.org/When/Coordinates/Common::Week::"}, # "@graph"=> # [{"rdf:type"=>{"@id"=>"http://hosi.org/ts/When/TM/CalDate"}, # "@id"=>"http://hosi.org/tp/明治05(1872)-12-", # "ts:sdn"=>2405158, # "ts:frame"=>{"@id"=>"http://hosi.org/When/CalendarTypes/Japanese"}, # "ts:calendarEra"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治"}, # "ts:coordinate"=>"12", # "ts:ruler"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇"}, # "@reverse"=>{"rdfs:member"=>{"@id"=>"http://hosi.org/tp/明治05(1872)"}}, # "MonthNote:月名"=>{"@id"=>"Month:十二月"}, # "MonthNote:廿八宿"=>{"@id"=>"LunarMansion:危宿"}, # "MonthNote:月建"=>{"@id"=>"Stem-Branch:癸丑"}, # "MonthNote:天道"=>"西行", # "MonthNote:天徳"=>"庚", # "MonthNote:月煞"=>"辰", # "MonthNote:用時"=>"乙丁辛亥", # "MonthNote:月徳"=>"庚", # "MonthNote:月徳合"=>"乙", # "MonthNote:月空"=>"甲", # "MonthNote:三鏡"=>"甲乙丁庚辛癸", # "MonthNote:土府"=>"子", # "MonthNote:土公"=>"庭", # "MonthNote:大小"=>"改(2)"}, # {"rdf:type"=>{"@id"=>"http://hosi.org/ts/When/TM/CalDate"}, # "@id"=>"http://hosi.org/tp/明治05(1872)-12-01", # "ts:sdn"=>2405158, # "ts:frame"=>{"@id"=>"http://hosi.org/When/CalendarTypes/Japanese"}, # "ts:calendarEra"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治"}, # "ts:coordinate"=>"1", # "ts:ruler"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇"}, # "@reverse"=>{"rdfs:member"=>{"@id"=>"http://hosi.org/tp/明治05(1872)-12-"}}, # "DayNote:干支"=>{"@id"=>"Stem-Branch:辛亥"}, # "DayNote:納音"=>"金", # "DayNote:十二直"=>"閉", # "DayNote:七曜"=>{"@id"=>"Week:Monday"}, # "DayNote:廿八宿"=>{"@id"=>"LunarMansion:張宿"}, # "DayNote:天一"=>"丑寅", # "DayNote:沐浴"=>"沐浴", # "DayNote:大小歳"=>"大歳位", # "DayNote:天恩"=>"天恩", # "DayNote:重"=>"重", # "DayNote:大明"=>"大明", # "DayNote:一粒万倍"=>"一粒万倍", # "DayNote:三寶吉"=>"三吉", # "DayNote:神吉"=>"神吉", # "DayNote:小字注"=>"裁衣市買納財塞穴吉"}, # {"rdf:type"=>{"@id"=>"http://hosi.org/ts/When/TM/CalDate"}, # "@id"=>"http://hosi.org/tp/明治05(1872)-12-02", # "ts:sdn"=>2405159, # "ts:frame"=>{"@id"=>"http://hosi.org/When/CalendarTypes/Japanese"}, # "ts:calendarEra"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治"}, # "ts:coordinate"=>"2", # "ts:ruler"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇"}, # "@reverse"=>{"rdfs:member"=>{"@id"=>"http://hosi.org/tp/明治05(1872)-12-"}}, # "DayNote:干支"=>{"@id"=>"Stem-Branch:壬子"}, # "DayNote:納音"=>"木", # "DayNote:十二直"=>"建", # "DayNote:七曜"=>{"@id"=>"Week:Tuesday"}, # "DayNote:廿八宿"=>{"@id"=>"LunarMansion:翼宿"}, # "DayNote:七十二候"=>"雪下出麦", # "DayNote:大將軍"=>"遊北", # "DayNote:天一"=>"丑寅", # "DayNote:六蛇"=>"六蛇", # "DayNote:凶会"=>"陰陽倶錯", # "DayNote:厭"=>"厭", # "DayNote:八專"=>"八專始", # "DayNote:一粒万倍"=>"一粒万倍", # "DayNote:小字注"=>"不為誓願不動財"}]}
Turtle 形式を扱うには json-ld gem と rdf-turtle gem が必要です。 (一括して gem install linkeddata, require 'linkeddata' してもかまいません)
#require 'linkeddata' # gem install linkeddata
require 'json/ld' # gem install json-ld require 'rdf/turtle' # gem install rdf-turtle puts When.when?('明治5.12').to_linked_data(:turtle, {'@context'=>{}, :context=>true, :included=>true, :include=>true}) #=> # @prefix DayNote: <http://hosi.org/When/CalendarNote/Japanese/Notes::日::> . # @prefix LunarMansion: <http://hosi.org/When/Coordinates/Common::宿::> . # @prefix Month: <http://hosi.org/When/BasicTypes/M17n/Japanese::Month::> . # @prefix MonthNote: <http://hosi.org/When/CalendarNote/Japanese/Notes::月::> . # @prefix Stem-Branch: <http://hosi.org/When/Coordinates/Common::干支::> . # @prefix Week: <http://hosi.org/When/Coordinates/Common::Week::> . # @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . # @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . # @prefix ts: <http://hosi.org/ts#> . # @prefix xsd: <http://www.w3.org/2001/XMLSchema> . # # <http://hosi.org/tp/明治05(1872)> rdfs:member <http://hosi.org/tp/明治05(1872)-12-> . # # <http://hosi.org/tp/明治05(1872)-12-> a <http://hosi.org/ts/When/TM/CalDate>; # MonthNote:三鏡 "甲乙丁庚辛癸"; # MonthNote:土公 "庭"; # MonthNote:土府 "子"; # MonthNote:大小 "改(2)"; # MonthNote:天徳 "庚"; # MonthNote:天道 "西行"; # MonthNote:廿八宿 LunarMansion:危宿; # MonthNote:月名 Month:十二月; # MonthNote:月建 Stem-Branch:癸丑; # MonthNote:月徳 "庚"; # MonthNote:月徳合 "乙"; # MonthNote:月煞 "辰"; # MonthNote:月空 "甲"; # MonthNote:用時 "乙丁辛亥"; # ts:calendarEra <http://hosi.org/When/TM/CalendarEra/Japanese::明治>; # ts:coordinate "12"; # ts:frame <http://hosi.org/When/CalendarTypes/Japanese>; # ts:ruler <http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇>; # ts:sdn 2405158; # rdfs:member <http://hosi.org/tp/明治05(1872)-12-01>, # <http://hosi.org/tp/明治05(1872)-12-02> . # # <http://hosi.org/tp/明治05(1872)-12-01> a <http://hosi.org/ts/When/TM/CalDate>; # DayNote:一粒万倍 "一粒万倍"; # DayNote:七曜 Week:Monday; # DayNote:三寶吉 "三吉"; # DayNote:十二直 "閉"; # DayNote:大小歳 "大歳位"; # DayNote:大明 "大明"; # DayNote:天一 "丑寅"; # DayNote:天恩 "天恩"; # DayNote:小字注 "裁衣市買納財塞穴吉"; # DayNote:干支 Stem-Branch:辛亥; # DayNote:廿八宿 LunarMansion:張宿; # DayNote:沐浴 "沐浴"; # DayNote:神吉 "神吉"; # DayNote:納音 "金"; # DayNote:重 "重"; # ts:calendarEra <http://hosi.org/When/TM/CalendarEra/Japanese::明治>; # ts:coordinate "1"; # ts:frame <http://hosi.org/When/CalendarTypes/Japanese>; # ts:ruler <http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇>; # ts:sdn 2405158 . # # <http://hosi.org/tp/明治05(1872)-12-02> a <http://hosi.org/ts/When/TM/CalDate>; # DayNote:一粒万倍 "一粒万倍"; # DayNote:七十二候 "雪下出麦"; # DayNote:七曜 Week:Tuesday; # DayNote:八專 "八專始"; # DayNote:六蛇 "六蛇"; # DayNote:凶会 "陰陽倶錯"; # DayNote:十二直 "建"; # DayNote:厭 "厭"; # DayNote:大將軍 "遊北"; # DayNote:天一 "丑寅"; # DayNote:小字注 "不為誓願不動財"; # DayNote:干支 Stem-Branch:壬子; # DayNote:廿八宿 LunarMansion:翼宿; # DayNote:納音 "木"; # ts:calendarEra <http://hosi.org/When/TM/CalendarEra/Japanese::明治>; # ts:coordinate "2"; # ts:frame <http://hosi.org/When/CalendarTypes/Japanese>; # ts:ruler <http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇>; # ts:sdn 2405159 .
hash = When::Parts::Resource.rdf_graph(When.when?('明治5.12.01')..When.when?('明治5.12.02'), {'@context'=>{}, :context=>true, :included=>true, :include=>true}) pp hash #=> # {"@context"=> # {"xsd"=>"http://www.w3.org/2001/XMLSchema", # "rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#", # "rdfs"=>"http://www.w3.org/2000/01/rdf-schema#", # "owl"=>"http://www.w3.org/2002/07/owl#", # "dc"=>"http://purl.org/dc/elements/1.1/", # "dcq"=>"http://purl.org/dc/terms/", # "dct"=>"http://purl.org/dc/dcmitype/", # "ts"=>"http://hosi.org/ts#", # "Stem-Branch"=>"http://hosi.org/When/Coordinates/Common::干支::", # "DayNote"=>"http://hosi.org/When/CalendarNote/Japanese/Notes::日::", # "Week"=>"http://hosi.org/When/Coordinates/Common::Week::", # "LunarMansion"=>"http://hosi.org/When/Coordinates/Common::宿::"}, # "@graph"=> # [{"rdf:type"=>{"@id"=>"http://hosi.org/ts/When/TM/CalDate"}, # "@id"=>"http://hosi.org/tp/明治05(1872)-12-01", # "ts:sdn"=>2405158, # "ts:frame"=>{"@id"=>"http://hosi.org/When/CalendarTypes/Japanese"}, # "ts:calendarEra"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治"}, # "ts:coordinate"=>"1", # "ts:ruler"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇"}, # "@reverse"=>{"rdfs:member"=>{"@id"=>"http://hosi.org/tp/明治05(1872)-12-"}}, # "DayNote:干支"=>{"@id"=>"Stem-Branch:辛亥"}, # "DayNote:納音"=>"金", # "DayNote:十二直"=>"閉", # "DayNote:七曜"=>{"@id"=>"Week:Monday"}, # "DayNote:廿八宿"=>{"@id"=>"LunarMansion:張宿"}, # "DayNote:天一"=>"丑寅", # "DayNote:沐浴"=>"沐浴", # "DayNote:大小歳"=>"大歳位", # "DayNote:天恩"=>"天恩", # "DayNote:重"=>"重", # "DayNote:大明"=>"大明", # "DayNote:一粒万倍"=>"一粒万倍", # "DayNote:三寶吉"=>"三吉", # "DayNote:神吉"=>"神吉", # "DayNote:小字注"=>"裁衣市買納財塞穴吉"}, # {"rdf:type"=>{"@id"=>"http://hosi.org/ts/When/TM/CalDate"}, # "@id"=>"http://hosi.org/tp/明治05(1872)-12-02", # "ts:sdn"=>2405159, # "ts:frame"=>{"@id"=>"http://hosi.org/When/CalendarTypes/Japanese"}, # "ts:calendarEra"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治"}, # "ts:coordinate"=>"2", # "ts:ruler"=> # {"@id"=>"http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇"}, # "@reverse"=>{"rdfs:member"=>{"@id"=>"http://hosi.org/tp/明治05(1872)-12-"}}, # "DayNote:干支"=>{"@id"=>"Stem-Branch:壬子"}, # "DayNote:納音"=>"木", # "DayNote:十二直"=>"建", # "DayNote:七曜"=>{"@id"=>"Week:Tuesday"}, # "DayNote:廿八宿"=>{"@id"=>"LunarMansion:翼宿"}, # "DayNote:七十二候"=>"雪下出麦", # "DayNote:大將軍"=>"遊北", # "DayNote:天一"=>"丑寅", # "DayNote:六蛇"=>"六蛇", # "DayNote:凶会"=>"陰陽倶錯", # "DayNote:厭"=>"厭", # "DayNote:八專"=>"八專始", # "DayNote:一粒万倍"=>"一粒万倍", # "DayNote:小字注"=>"不為誓願不動財"}]}
puts When::Parts::Resource.to_linked_data(hash, :turtle, hash['@context']) #=> # @prefix DayNote: <http://hosi.org/When/CalendarNote/Japanese/Notes::日::> . # @prefix LunarMansion: <http://hosi.org/When/Coordinates/Common::宿::> . # @prefix Stem-Branch: <http://hosi.org/When/Coordinates/Common::干支::> . # @prefix Week: <http://hosi.org/When/Coordinates/Common::Week::> . # @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . # @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . # @prefix ts: <http://hosi.org/ts#> . # @prefix xsd: <http://www.w3.org/2001/XMLSchema> . # # <http://hosi.org/tp/明治05(1872)-12-> rdfs:member <http://hosi.org/tp/明治05(1872)-12-01>, # <http://hosi.org/tp/明治05(1872)-12-02> . # # <http://hosi.org/tp/明治05(1872)-12-01> a <http://hosi.org/ts/When/TM/CalDate>; # DayNote:一粒万倍 "一粒万倍"; # DayNote:七曜 Week:Monday; # DayNote:三寶吉 "三吉"; # DayNote:十二直 "閉"; # DayNote:大小歳 "大歳位"; # DayNote:大明 "大明"; # DayNote:天一 "丑寅"; # DayNote:天恩 "天恩"; # DayNote:小字注 "裁衣市買納財塞穴吉"; # DayNote:干支 Stem-Branch:辛亥; # DayNote:廿八宿 LunarMansion:張宿; # DayNote:沐浴 "沐浴"; # DayNote:神吉 "神吉"; # DayNote:納音 "金"; # DayNote:重 "重"; # ts:calendarEra <http://hosi.org/When/TM/CalendarEra/Japanese::明治>; # ts:coordinate "1"; # ts:frame <http://hosi.org/When/CalendarTypes/Japanese>; # ts:ruler <http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇>; # ts:sdn 2405158 . # # <http://hosi.org/tp/明治05(1872)-12-02> a <http://hosi.org/ts/When/TM/CalDate>; # DayNote:一粒万倍 "一粒万倍"; # DayNote:七十二候 "雪下出麦"; # DayNote:七曜 Week:Tuesday; # DayNote:八專 "八專始"; # DayNote:六蛇 "六蛇"; # DayNote:凶会 "陰陽倶錯"; # DayNote:十二直 "建"; # DayNote:厭 "厭"; # DayNote:大將軍 "遊北"; # DayNote:天一 "丑寅"; # DayNote:小字注 "不為誓願不動財"; # DayNote:干支 Stem-Branch:壬子; # DayNote:廿八宿 LunarMansion:翼宿; # DayNote:納音 "木"; # ts:calendarEra <http://hosi.org/When/TM/CalendarEra/Japanese::明治>; # ts:coordinate "2"; # ts:frame <http://hosi.org/When/CalendarTypes/Japanese>; # ts:ruler <http://hosi.org/When/TM/CalendarEra/Japanese::明治::明治天皇>; # ts:sdn 2405159 .
SPARQL endpoint として http://hosi.org/japan/sparql を提供しています。
西暦593年から2050年までの日本暦注の検索が可能です。
下記は日本最古の具注暦(奈良県明日香村石神遺跡出土)の日付を検索した例です。
require 'sparql/client' # gem install sparql PREFIXES = When::Parts::Resource.namespace_prefixes( '_co:Common', '_co:Common?V=0618', '_m:Calendar', '_m:Japanese', '_n:Japanese/Notes') client = SPARQL::Client.new("http://hosi.org/japan/sparql") client.query(PREFIXES.keys.map {|key| "PREFIX #{key}: <#{PREFIXES[key].last}> "}.join("\n") + %( SELECT DISTINCT ?s WHERE { ?s ts:coordinate "10" . ?s DayNote:廿四節気 SolarTerm:清明 . ?s DayNote:干支 Stem-Branch:壬戌 . } )).each do |solution| pp solution[:s].to_s #=> end # "http://hosi.org/tp/0689-03-10%5E%5EJapanese" # "http://hosi.org/tp/1490-03-10%5E%5EJapanese"