Weitere ähnliche Inhalte Ähnlich wie スキーマとURI (20) Mehr von Fumihiro Kato (20) Kürzlich hochgeladen (11) スキーマとURI5. URI: Uniform Resource Identifier
• リソースの識別子
• 世界中で特定可能な仕組み
• http://fumi.me
• http://fumi.me/foaf#me
• mailto:fumi@fumi.me
• tel:+81-3-4212-2658
• urn:isbn:9784764904279
5
12. 1. request /resource/Japan
2. return an HTML document for /resource/Japan
http://dbpedia.orgWeb Browser
% curl -ILH 'Accept: text/html' http://dbpedia.org/resource/Japan
HTTP/1.1 303 See Other
Date: Thu, 04 Jul 2013 09:30:17 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
Server: Virtuoso/07.00.3203 (Linux) i686-generic-linux-glibc212-64 VDB
Accept-Ranges: bytes
Location: http://dbpedia.org/page/Japan
!
HTTP/1.1 200 OK
Date: Thu, 04 Jul 2013 09:31:07 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 2023382
Connection: keep-alive
Vary: Accept-Encoding
.....
!
13. 1. request /resource/Japan
2. return a turtle document for /resource/Japan
http://dbpedia.orgLOD Agent
@prefix yago-res: <http://mpii.de/yago/resource/> .
@prefix dbpedia: <http://dbpedia.org/resource/> .
yago-res:Japan owl:sameAs dbpedia:Japan .
<http://data.nytimes.com/59436095099277148161> owl:sameAs
dbpedia:Japan .
<http://data.nytimes.com/66220885916538669281> owl:sameAs
dbpedia:Japan .
@prefix dbpedia-owl: <http://dbpedia.org/ontology/> .
dbpedia:Ayumi_Hamasaki dbpedia-owl:hometown dbpedia:Japan ;
dbpedia-owl:birthPlace dbpedia:Japan .
dbpedia:Nippon_Columbia dbpedia-owl:distributingCompany dbpedia:Japan ;
dbpedia-owl:distributingLabel dbpedia:Japan ;
dbpedia-owl:country dbpedia:Japan .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix yago: <http://dbpedia.org/class/yago/> .
dbpedia:Japan rdf:type yago:EastAsianCountries ,
owl:Thing .
@prefix ns6: <http://schema.org/> .
dbpedia:Japan rdf:type ns6:Country ,
yago:CountriesBorderingThePhilippineSea ,
yago:Empires ,
yago:IslandCountries ,
yago:StatesAndTerritoriesEstablishedIn660BC ,
dbpedia-owl:Country ,
dbpedia-owl:PopulatedPlace ,
ns6:Place ,
yago:CountriesBorderingThePacificOcean .
@prefix ns7: <http://umbel.org/umbel/rc/> .
dbpedia:Japan rdf:type ns7:Country ,
ns7:PopulatedPlace ,
dbpedia-owl:Place ,
yago:OECDMemberEconomies .
% curl -ILH 'Accept: text/turtle' http://dbpedia.org/resource/Japan
HTTP/1.1 303 See Other
Date: Thu, 04 Jul 2013 09:36:52 GMT
Content-Type: text/turtle; qs=0.7
Content-Length: 0
Connection: keep-alive
Server: Virtuoso/07.00.3203 (Linux) i686-generic-linux-glibc212-64 VDB
TCN: choice
Vary: negotiate,accept
Link: <http://mementoarchive.lanl.gov/dbpedia/timegate/http://
dbpedia.org/resource/Japan>; rel="timegate"
Location: http://dbpedia.org/data/Japan.ttl
!
HTTP/1.1 200 OK
Date: Thu, 04 Jul 2013 09:36:52 GMT
Content-Type: text/turtle; charset=UTF-8
Content-Length: 1967774
Connection: keep-alive
......
16. 200 OK
Accept: text/html
200 OK
Accept: application/rdf+xml
http://www.w3.org/People/
Berners-Lee/card
#以下削除
HTML Doc
RDF/XML Doc
http://www.w3.org/
People/Berners-Lee/
card#i
ハッシュ例: TimBL
16
21. 省略記法の良くあるミス
• 省略されたURIと完全なURIは構造的には明示的に区別できない
• (なんで区切り文字を : にしたのか)
• ex:テストは ex: というprefixと テストの組み合わせの省略されたURIなのか,exというschemeのURIなのか
• Turtle
• 完全なURIは <>で囲む.省略記法は<>で囲まない
• ○ <http://xmlns.com/foaf/0.1/name>, foaf:name
• <foaf:name> <= foaf:name というURIだと解釈される
• RDF/XML
• rdf:aboutやrdf:resource(XML属性)の値には省略記法で書けない.要素には書ける(但し制約あり)
• ○ <rdf:Description rdf:about= http://xmlns.com/foaf/0.1/Person >
• <rdf:Description rdf:about= foaf:Person >
25. 語彙とスキーマ
• RDFにおける語彙
• 用語: クラスとプロパティ
• 語彙: クラスとプロパティ
の集合
• クラス: リソースが属する
グループ (分類・概念)
• プロパティ: リソースの属
性,リソース間の関係
• スキーマ言語
• RDFで用いる語彙を定義
する方法
• RDFS: 基本的な言語
• OWL: より詳細に知識を
表現するための言語
• 実際にはRDFSやOWLも
RDF語彙
25
28. プロパティ
• リソースの属性やリソース間の関係
• プロパティもリソース (rdf:Propertyのインスタンス)
• プロパティの前後にくるリソースのクラスを指定可能
• ex:タロー ex:like ex:ハナコ .
• ex:like a rdf:Property; rdfs:domain ex:動物;
rdfs:range rdfs:Resource .
28
33. Dublin Core
• Dublin Core Metadata Initiativeによる策定
• リソースを記述するための基本語彙
• 元々書誌から派生
• DCMES: Dublin Core Metadata Element Set, Version 1.1
• DCTERMS: DCMI Metadata Terms
33
34. Dublin Core Metadata
Element Set, Version 1.1
• Simple Dublin Core
• 15の基本プロパティ
• http://dublincore.org/documents/dces/
34
@prefix dc: <http://purl.org/dc/elements/1.1/>
@prefix ex: <http://example.org/ex/>
!
ex:001 dc:title ファイブスター物語 1 ;
dc:date 1987-05-21 ;
dc:creator 永野 護 .
35. <http://purl.org/dc/elements/1.1/title>
dcterms:hasVersion <http://dublincore.org/usage/terms/history/#title-006> ;
dcterms:issued "1999-07-02"^^<http://www.w3.org/2001/XMLSchema#date> ;
dcterms:modified "2008-01-14"^^<http://www.w3.org/2001/XMLSchema#date> ;
a rdf:Property ;
rdfs:comment "A name given to the resource."@en ;
rdfs:isDefinedBy <http://purl.org/dc/elements/1.1/> ;
rdfs:label "Title"@en ;
skos:note "A second property with the same name as this property has been declared in
the dcterms: namespace (http://purl.org/dc/terms/). See the Introduction to the
document "DCMI Metadata Terms" (http://dublincore.org/documents/dcmi-terms/) for
an explanation."@en .
36. DCMI Metadata Terms
• DCMESの後継
• DCMESを全て引き継いだ上で再定義・拡張
36
@prefix dcterms: <http://purl.org/dc/terms/>
@prefix ex: <http://example.org/ex/>
!
ex:001 dcterms:title ファイブスター物語 1 ;
dcterms:issued 1987-05-21 ;
dcterms:creator ex:永野護 ;
dcterms:publisher ex:角川書店 .
37. dcterms:issued
dcterms:hasVersion <http://dublincore.org/usage/terms/history/#issued-003> ;
dcterms:issued "2000-07-11"^^<http://www.w3.org/2001/XMLSchema#date> ;
dcterms:modified "2008-01-14"^^<http://www.w3.org/2001/XMLSchema#date> ;
a rdf:Property ;
rdfs:comment "Date of formal issuance (e.g., publication) of the resource."@en ;
rdfs:isDefinedBy <http://purl.org/dc/terms/> ;
rdfs:label "Date Issued"@en ;
rdfs:range rdfs:Literal ;
rdfs:subPropertyOf <http://purl.org/dc/elements/1.1/date>, dcterms:date .
!
dcterms:creator
dcterms:description "Examples of a Creator include a person, an organization, or a
service."@en ;
dcterms:hasVersion <http://dublincore.org/usage/terms/history/#creatorT-002> ;
dcterms:issued "2008-01-14"^^<http://www.w3.org/2001/XMLSchema#date> ;
dcterms:modified "2010-10-11"^^<http://www.w3.org/2001/XMLSchema#date> ;
a rdf:Property ;
rdfs:comment "An entity primarily responsible for making the resource."@en ;
rdfs:isDefinedBy <http://purl.org/dc/terms/> ;
rdfs:label "Creator"@en ;
rdfs:range dcterms:Agent ;
rdfs:subPropertyOf <http://purl.org/dc/elements/1.1/creator>, dcterms:contributor ;
owl:equivalentProperty <http://xmlns.com/foaf/0.1/maker> .
39. FOAF: Friend of a Friend
• 人についての語彙
• 有志による策定
• http://www.foaf-project.org
@prefix foaf: <http://xmlns.com/foaf/0.1/>
@prefix dcterms: <http://purl.org/dc/terms/>
@prefix ex: <http://example.org/ex/>
!
ex:永野護 a foaf:Person ;
foaf:name 永野 護 @ja, Mamoru Nagano @en ;
foaf:nick クリス @ja, Chris @en ;
foaf:homepage <http://automaticflowers.ne.jp> .
40. (http://xmlns.com/foaf/spec/index.rdf)
!
<rdfs:Class rdf:about="http://xmlns.com/foaf/0.1/Person" rdfs:label="Person"
rdfs:comment="A person." vs:term_status="stable">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class" />
<owl:equivalentClass rdf:resource="http://schema.org/Person" />
<owl:equivalentClass rdf:resource="http://www.w3.org/2000/10/swap/pim/
contact#Person" />
<rdfs:subClassOf><owl:Class rdf:about="http://xmlns.com/foaf/0.1/Agent"/></
rdfs:subClassOf>
<rdfs:subClassOf><owl:Class rdf:about="http://www.w3.org/2003/01/geo/
wgs84_pos#SpatialThing" rdfs:label="Spatial Thing"/></rdfs:subClassOf>
<rdfs:isDefinedBy rdf:resource="http://xmlns.com/foaf/0.1/"/>
<owl:disjointWith rdf:resource="http://xmlns.com/foaf/0.1/Organization"/>
<owl:disjointWith rdf:resource="http://xmlns.com/foaf/0.1/Project"/>
</rdfs:Class>
41. Schema.org
• 検索エンジン各社が共同で整備する広範囲の語彙
• http://schema.org
• W3Cのグループ: public-vocab@w3.org
• 有志によるスキーマが公開
• http://schema.rdfs.org
• 公式版のスキーマもあるが文法ミスだらけなので参考程度
@prefix schema: <http://schema.org/>
@prefix ex: <http://example.org/ex/>
!
ex:GTM a schema:Movie ;
schema:director ex:永野護 ;
schema:author ex:永野護 ;
schema:actor ex:川村万梨阿 ;
schema:productionCompany ex:オートマチック・フラワーズ・スタジオ ;
schema:publisher ex:角川書店 ;
schema:datePublished 2012-11-01 .
42. (http://schema.rdfs.org/all.tll)
!
schema:Organization a rdfs:Class;
rdfs:label "Organization"@en;
rdfs:comment ""@en;
rdfs:subClassOf schema:Thing;
rdfs:isDefinedBy <http://schema.org/Organization>;
!
schema:address a rdf:Property;
rdfs:label "Address"@en;
rdfs:comment "Physical address of the item."@en;
rdfs:domain [ a owl:Class; owl:unionOf (schema:Person schema:Place
schema:Organization) ];
rdfs:range schema:PostalAddress;
rdfs:isDefinedBy <http://schema.org/Person>;
rdfs:isDefinedBy <http://schema.org/Place>;
rdfs:isDefinedBy <http://schema.org/Organization>;
.
43. % curl -H 'Accept: application/ld+json' http://schema.org
{
"@context": {
"@vocab": "http://schema.org/",
"acceptsReservations": { "@type": "@id" },
"additionalType": { "@type": "@id" },
"applicationCategory": { "@type": "@id" },
"applicationSubCategory": { "@type": "@id" },
"arrivalTime": { "@type": "DateTime" },
"availabilityEnds": { "@type": "DateTime" },
"availabilityStarts": { "@type": "DateTime" },
"availableFrom": { "@type": "DateTime" },
…
45. SKOS: Simple Knowledge Organization System
• 概念階層の記述用語彙
• W3C勧告
• シソーラス,タクソノミ,分類,件名標目,トピック
• 階層関係が厳密でない: 下位概念のものが上位概念も満たすとは限らない
• skos:broader, skos:narrower, skos:related (これらは推移的ではない)
• RDFS/OWL
• 用語間の包摂関係: 下位概念は上位概念も満たす
47. @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix skos: <http://www.w3.org/2004/02/skos/core#>.
@prefix xl: <http://www.w3.org/2008/05/skos-xl#>.
@prefix rda: <http://RDVocab.info/ElementsGr2/>.
@prefix frbrent: <http://RDVocab.info/uri/schema/FRBRentitiesRDA/>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix ndl: <http://ndl.go.jp/dcndl/terms/>.
@prefix dct: <http://purl.org/dc/terms/>.
!
<http://id.ndl.go.jp/auth/ndlsh/00574798>
rdf:type <http://www.w3.org/2004/02/skos/core#Concept>;
dct:modified "2011-10-27T23:59:59";
dct:created "1980-06-20";
xl:prefLabel [xl:literalForm "人工知能";ndl:transcription "ジンコウチノウ"@ja-Kana,"Jinkochino"@ja-Latn];
rdfs:label "人工知能";
dct:source "電子計算機と人間 / ドナルド・G. フィンク 著 ; 高橋秀俊, 石田晴久 訳","広辞苑 第5版";
skos:exactMatch <http://id.ndl.go.jp/auth/bsh4/00536700>;
skos:inScheme <http://id.ndl.go.jp/auth#topicalTerms>;
xl:altLabel [xl:literalForm "人工頭脳";ndl:transcription "ジンコウズノウ"@ja-Kana,"Jinkozuno"@ja-Latn],[xl:literalForm
"AI"],[xl:literalForm "Artificial intelligence"];
skos:historyNote "人工頭脳→人工知能 (20031218)";
skos:closeMatch <http://id.loc.gov/authorities/subjects/sh85008180>;
skos:relatedMatch <http://id.ndl.go.jp/class/ndlc/M121>,<http://id.ndl.go.jp/class/ndc9/007.13>;
skos:related <http://id.ndl.go.jp/auth/ndlsh/00567826>,<http://id.ndl.go.jp/auth/ndlsh/00569072>,<http://
id.ndl.go.jp/auth/ndlsh/01017770>,<http://id.ndl.go.jp/auth/ndlsh/01182274>;
skos:broader <http://id.ndl.go.jp/auth/ndlsh/00575008>;
skos:narrower <http://id.ndl.go.jp/auth/ndlsh/00576312>,<http://id.ndl.go.jp/auth/ndlsh/01165604>;
owl:sameAs <http://id.ndl.go.jp/auth/ndlsh/人工知能>.
<http://id.ndl.go.jp/auth/ndlsh/00567826> rdfs:label "問題解決".
<http://id.ndl.go.jp/auth/ndlsh/00569072> rdfs:label "パターン認識".
<http://id.ndl.go.jp/auth/ndlsh/01017770> rdfs:label "オントロジー (情報科学)".
<http://id.ndl.go.jp/auth/ndlsh/01182274> rdfs:label "ソフトコンピューティング".
<http://id.ndl.go.jp/auth/ndlsh/00575008> rdfs:label "情報科学".
<http://id.ndl.go.jp/auth/ndlsh/00576312> rdfs:label "エキスパートシステム".
<http://id.ndl.go.jp/auth/ndlsh/01165604> rdfs:label "ニューラルネットワーク".
48. (http://www.w3.org/TR/skos-reference/skos.rdf)
!
<rdf:Description rdf:about="#broader">
<rdfs:label xml:lang="en">has broader</rdfs:label>
<rdfs:isDefinedBy rdf:resource="http://www.w3.org/2004/02/skos/core"/>
<skos:definition xml:lang="en">Relates a concept to a concept that is more general in
meaning.</skos:definition>
<rdfs:comment xml:lang="en">Broader concepts are typically rendered as parents in a
concept hierarchy (tree).</rdfs:comment>
<skos:scopeNote xml:lang="en">By convention, skos:broader is only used to assert an
immediate (i.e. direct) hierarchical link b
etween two conceptual resources.</skos:scopeNote>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
<rdfs:subPropertyOf rdf:resource="#broaderTransitive"/>
<owl:inverseOf rdf:resource="#narrower"/>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
</rdf:Description>
49. geo: Basic Geo Vocabulary
• 基本位置情報語彙: 世界測地系(WGS84)
• W3Cコミュニティ
• http://www.w3.org/2003/01/geo/
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
@prefix ex: <http://example.org/ex/>
!
ex:さくらWORKS<関内> a geo:SpatialThing ;
geo:lat 35.44658 ^^xsd:float ;
geo:long 139.63782 ^^xsd:float .
51. cc: Creative Commons
• CCライセンスを記述するための語彙
• Creative Commons Rights Expression Language (CC REL)
• Creative Commonsによって管理
• http://creativecommons.org/CcREL
@prefix cc: <http://creativecommons.org/ns#>
@prefix ex: <http://example.org/ex/>
!
ex:プレゼン資料 cc:attributionName Fumihiro Kato ;
cc:attributionURL <http://fumi.me> ;
cc:license <http://creativecommons.org/licenses/by/4.0> .
52. <rdfs:Class rdf:about="http://creativecommons.org/ns#License">
<rdfs:label xml:lang="en-US">License</rdfs:label>
<rdfs:comment xml:lang="en-US">a set of
requests/permissions to users of a Work, e.g. a
copyright license, the public domain, information
for distributors</rdfs:comment>
<rdfs:subClassOf rdf:resource="http://purl.org/dc/terms/LicenseDocument"/>
</rdfs:Class>
<rdf:Property rdf:about="http://creativecommons.org/ns#license">
<rdfs:range rdf:resource="http://creativecommons.org/ns#License"/>
<rdfs:domain rdf:resource="http://creativecommons.org/ns#Work"/>
<owl:sameAs rdf:resource="http://www.w3.org/1999/xhtml/vocab#license"/>
<rdfs:subPropertyOf rdf:resource="http://purl.org/dc/terms/license"/>
<rdfs:label xml:lang="en-US">has
license</rdfs:label>
</rdf:Property>
53. VoID: Describing Linked Datasets
with the VoID Vocabulary
• LODのデータセットを記述するための言語
• W3Cノート
• LODクラウド作るのにも使用されている
@prefix void: <http://rdfs.org/ns/void#> .
@prefix : <http://ja.dbpedia.org/void.ttl#> .
!
:DBpediaJA a void:Dataset ;
dcterms:title "DBpedia Japanese"@en, "DBpedia Japanese"@ja ;
dcterms:description "DBpedia Japanese provides RDF datasets extracted from Japanese Wikipedia" ;
dcterms:creator <http://fumi.me/foaf#me> ;
dcterms:publisher :LODAC ;
dcterms:contributor :NII, :ROIS, :DBpediaCommunity ;
dcterms:source <http://ja.dbpedia.org/page/Wikipedia> ;
dcterms:created "2012-05-09"^^xsd:date ;
dcterms:license <http://creativecommons.org/licenses/by-sa/3.0/> ;
foaf:homepage <http://ja.dbpedia.org> ;
foaf:page <http://datahub.io/dataset/dbpedia-ja> ;
void:sparqlEndpoint <http://ja.dbpedia.org/sparql> ;
void:triples 70790371 ;
void:feature <http://www.w3.org/ns/formats/RDF_XML>, <http://www.w3.org/ns/formats/N3>, <http://
www.w3.org/ns/formats/RDFa> .
54. void:Dataset a rdfs:Class, owl:Class;
rdfs:label "dataset";
rdfs:comment "A set of RDF triples that are published, maintained or aggregated by a
single provider." .
!
void:Linkset a rdfs:Class, owl:Class;
rdfs:label "linkset";
rdfs:comment "A collection of RDF links between two void:Datasets.";
rdfs:subClassOf void:Dataset .
!
void:sparqlEndpoint a rdf:Property;
rdfs:label "has a SPARQL endpoint at";
rdfs:domain void:Dataset .
56. DCAT: Data Catalog Vocabulary
• データカタログ用語彙
• W3C勧告, http://www.w3.org/TR/vocab-dcat/
• 主にDCTermsやSKOSと組み合わせて使うことを想定
• CKANやSocrataといったソフトウェアが採用
@prefix foaf: <http://xmlns.com/foaf/0.1/>
@prefix dcterms: <http://purl.org/dc/terms/>
@prefix dcat: <http://www.w3.org/ns/dcat#>
@prefix ex: <http://example.org/ex/>
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
!
ex:dataset-1 a dcat:Dataset ;
dcterms:title 横浜市 人口統計 2010年度版 ;
dcat:keyword 統計 ;
dcterms:issued 2011-03-31 ^^xsd:date ;
dcterms:publisher ex:横浜市 ;
dcat:distribution [ a dcat:Distribution ;
dcat:downloadURL <http://example.org/files/dataset-1.csv> ;
dcterms:title 横浜市 人口統計 2010年度版 CSVデータ ;
dcat:mediaType text/csv ;
dcat:byteSize 10000
] .
57. The Organization Ontology
• 組織用語彙
• 組織構造,役職等
• W3C勧告, http://www.w3.org/TR/vocab-org/
vocab-orgからの実例
!
<http://reference.data.gov.uk/id/department/co>
rdf:type org:Organization , central-government:Department;
skos:prefLabel "Cabinet Office" ;
org:hasUnit <http://reference.data.gov.uk/id/department/co/unit/cabinet-office-communications> .
<http://reference.data.gov.uk/id/department/co/unit/cabinet-office-communications>
rdf:type org:OrganizationalUnit ;
skos:prefLabel "Cabinet Office Communications" ;
org:unitOf <http://reference.data.gov.uk/id/department/co> ;
org:hasPost <http://reference.data.gov.uk/id/department/co/post/246> .
!
<http://reference.data.gov.uk/id/department/co/post/246>
skos:prefLabel "Deputy Director, Deputy Prime Minister's Spokesperson/Head of Communications" .
org:postIn <http://reference.data.gov.uk/id/department/co/unit/cabinet-office-communications> ;
org:heldBy <#person161> .
58. The RDF Data Cube Vocabulary
• 統計データ用語彙
• W3C勧告, http://www.w3.org/TR/vocab-data-cube/
• SDMX (Statistical Data and Metadata eXchange) との互換性
eg:dsd1 a qb:DataStructureDefinition;
rdfs:comment "shipments by time (multiple measures approach)"@en;
qb:component
[ qb:dimension sdmx-dimension:refTime; ],
[ qb:measure eg-measure:quantity; ],
[ qb:measure eg-measure:weight; ] .
!
eg:dataset1 a qb:DataSet;
qb:structure eg:dsd1 .
eg:obs1a a qb:Observation;
qb:dataSet eg:dataset1;
sdmx-dimension:refTime "2010-07-30"^^xsd:date;
eg-measure:weight 1.3 ;
eg-measure:quantity 42 ;
.