@@ -22,6 +22,7 @@ options = {
2222OPT_ARGS = [
2323 [ "--body" , GetoptLong ::NO_ARGUMENT , "Include the vocabulary definition in the body of the document" ] ,
2424 [ "--hierarchical" , GetoptLong ::NO_ARGUMENT , "Create a hierachy using 'children' as reverse of rdfs:subClassOf" ] ,
25+ [ "--initial" , GetoptLong ::REQUIRED_ARGUMENT , "Initial context to load, overrides default" ] ,
2526 [ "--language" , GetoptLong ::REQUIRED_ARGUMENT , "Default language for vocabulary" ] ,
2627 [ "--output" , "-o" , GetoptLong ::REQUIRED_ARGUMENT , "Output to the specified file path" ] ,
2728 [ "--prefix" , GetoptLong ::REQUIRED_ARGUMENT , "space-separated prefix uri combination" ] ,
@@ -45,12 +46,28 @@ def usage
4546 exit ( 1 )
4647end
4748
49+ base_context = ::JSON . parse %({
50+ "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
51+ "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
52+ "rdfs:domain": {"@type": "@id"},
53+ "rdfs:range": {"@type": "@id"},
54+ "rdfs:subClassOf": {"@type": "@id"},
55+ "rdfs:subPropertyOf": {"@type": "@id"},
56+ "owl": "http://www.w3.org/2002/07/owl#",
57+ "owl:equivalentClass": {"@type": "@vocab"},
58+ "owl:equivalentProperty": {"@type": "@vocab"},
59+ "owl:oneOf": {"@container": "@list", "@type": "@vocab"},
60+ "owl:imports": {"@type": "@id"},
61+ "owl:versionInfo": {"@type": "xsd:string", "@language": null},
62+ "owl:inverseOf": {"@type": "@vocab"}
63+ })
4864
4965opts = GetoptLong . new ( *OPT_ARGS . map { |o | o [ 0 ..-2 ] } )
5066
5167opts . each do |opt , arg |
5268 case opt
5369 when '--body' then options [ :include_body ] = true
70+ when '--initial' then base_context = ::JSON . parse ( File . read ( arg ) )
5471 when '--hierarchical' then options [ :hier ] = true
5572 when '--language' then options [ :language ] = arg
5673 when '--output' then options [ :output ] = File . open ( arg , "w" )
6481# Load vocabulary
6582graph = RDF ::Graph . load ( ARGV [ 0 ] )
6683
67- base_context = {
68- "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ,
69- "rdfs" => "http://www.w3.org/2000/01/rdf-schema#" ,
70- "rdfs:domain" => { "@type" => "@id" } ,
71- "rdfs:range" => { "@type" => "@id" } ,
72- "rdfs:subClassOf" => { "@type" => "@id" } ,
73- "rdfs:subPropertyOf" => { "@type" => "@id" } ,
74- "owl" => "http://www.w3.org/2002/07/owl#" ,
75- "owl:equivalentClass" => { "@type" => "@vocab" } ,
76- "owl:equivalentProperty" => { "@type" => "@vocab" } ,
77- "owl:oneOf" => { "@container" => "@list" , "@type" => "@vocab" } ,
78- "owl:imports" => { "@type" => "@id" } ,
79- "owl:versionInfo" => { "@type" => "xsd:string" , "@language" => nil } ,
80- "owl:inverseOf" => { "@type" => "@vocab" } ,
81- }
82-
8384context = JSON ::LD ::Context . new ( options ) .
8485 parse ( base_context ) .
8586 from_vocabulary ( graph )
0 commit comments