Sha256: b01114f81a9ceb93f152bbb6d3fedf97bcdca6af4f0c485a441df6b32ef99fd7

Contents?: true

Size: 1.17 KB

Versions: 51

Compression:

Stored size: 1.17 KB

Contents

# This file will generate a hash of LC more specific terms from the to-level term defined below (currently "Automobiles").
# It then dumps this hash to a file, so it can be loaded with each pre-assembly run and used when generating Revs Descriptive Metadata
# This method can be run periodically to refresh the list of terms.  It will generate a new file in the "lib/pre_assembly/project" folder
# which can be updated in git.

# Peter Mangiafico
# May 16, 2013

require File.expand_path(File.dirname(__FILE__) + '/../config/boot')
require 'rdf'
require 'rdf/ntriples'

automobile_term='http://id.loc.gov/authorities/subjects/sh85010201' # the top-level LC term to get RDF for, "Automobiles"
term_predicate='http://www.w3.org/2004/02/skos/core#prefLabel' # the predicate which tells us when we have a term defined 

results={} # the hash we will write with the terms and their LC URLs

RDF::Reader.open("#{automobile_term}.nt") do |reader|
  reader.each_statement do |statement|
    if statement.predicate.to_s.strip == term_predicate
      results.merge!({statement.object.to_s=>statement.subject.to_s})
    end
  end
end

File.open(REVS_LC_TERMS_FILENAME, "wb") {|f| Marshal.dump(results, f)}

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
revs-utils-2.2.0 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.25 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.24 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.23 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.22 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.21 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.20 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.19 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.18 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.17 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.16 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.15 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.14 bin/revs_lc_automobile_terms.rb
revs-utils-1.0.21 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.13 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.12 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.11 bin/revs_lc_automobile_terms.rb
revs-utils-1.0.20 bin/revs_lc_automobile_terms.rb
revs-utils-1.0.19 bin/revs_lc_automobile_terms.rb
revs-utils-2.1.10 bin/revs_lc_automobile_terms.rb