Skip to content

Instantly share code, notes, and snippets.

View no-reply's full-sized avatar

tamsin woo no-reply

  • UC Santa Barbara Library
  • United States
View GitHub Profile
@no-reply
no-reply / bag_import_error.rb
Created August 5, 2013 19:16
Blobs of bagit-for-hydra stuff
module Hybag
class BagImportError < StandardError
end
end
@no-reply
no-reply / bag_import_error.rb
Created August 5, 2013 19:16
Blobs of bagit-for-hydra stuff
module Hybag
class BagImportError < StandardError
end
end
@no-reply
no-reply / nt2bag.rb
Created August 6, 2013 17:04
Some ugly Ruby for stuffing processed ContentDM metadata into bags.
require 'rdf'
require 'rdf/ntriples'
require 'bagit'
graph = RDF::Graph.load('braceros.nt')
graph.each_subject do |subject|
bag = BagIt::Bag.new(File.basename(subject))
RDF::Writer.open("descMetadata.nt", :format => :ntriples) do |writer|
query = RDF::Query.new do
@no-reply
no-reply / RDF Samples
Last active December 26, 2015 03:39
Oregon Digital RDF
<http://example.org/ns/1540> <http://purl.org/dc/terms/title> "The chop-house rag" .
<http://example.org/ns/1540> <http://id.loc.gov/vocabulary/relators/cmp> "Fowler, Edna May" .
<http://example.org/ns/1540> <http://purl.org/dc/terms/date> "1911" .
<http://example.org/ns/1540> <http://purl.org/dc/terms/description> "Back cover is an advertisement for the \"GEM dance folio for 1912\" printed in red ink." .
<http://example.org/ns/1540> <http://purl.org/dc/terms/description> "A small portrait of Artie Hall is in the lower right corner. In the center of the page is an illustration of a waiter and a cook dancing along with a dancing tomato, sausages, lobster, and oyster." .
<http://example.org/ns/1540> <http://www.loc.gov/standards/mods/modsrdf/v1/genre> "Sheet music" .
<http://example.org/ns/1540> <http://tom.oregonstate.edu/coverArtist> "Starmer" .
<http://example.org/ns/1540> <http://www.loc.gov/mads/rdf/v1#Collection> "University of Oregon Libraries - Music Services" .
<http://example.org/ns/1540> <http://pur
@no-reply
no-reply / oregon_rdf_demo.rb
Last active July 12, 2017 00:14
RDF Resources in OregonDigital
# RdfResource is a subclass of RDF::Graph with property configuration, accessors, and some other methods
# for managing "resources" as discrete subgraphs which can be managed by a Hydra datastream model.
#
# The relevant modules and class are:
#
# https://github.com/OregonDigital/oregondigital/tree/master/lib/oregon_digital/rdf/rdf_configurable.rb
# https://github.com/OregonDigital/oregondigital/tree/master/lib/oregon_digital/rdf/rdf_properties.rb
# https://github.com/OregonDigital/oregondigital/tree/master/lib/oregon_digital/rdf/rdf_resource.rb
bnode = OregonDigital::RDF::RdfResource.new
@no-reply
no-reply / vocabs.rb
Last active January 4, 2016 03:39
Using Vocabulary Loader
# The ruby-rdf vocabulary loader is used to maintain the vocabularies in the core library.
# There's a rake task that is the main way it is used and serves as a good reference.
# https://github.com/ruby-rdf/rdf/blob/develop/Rakefile
rake gen_vocabs
# Generate lib/rdf/vocab/cc.rb
# Generate lib/rdf/vocab/cert.rb
# Generate lib/rdf/vocab/dc.rb
# Generate lib/rdf/vocab/dc11.rb
@no-reply
no-reply / rdf_demo.rb
Last active August 29, 2015 13:57
A Demo of ActiveFedora::Rdf in 7.x
# RdfResource is a subclass of RDF::Graph with property configuration, accessors, and some other methods
# for managing "resources" as discrete subgraphs which can be managed by a Hydra datastream model.
bnode = ActiveFedora::Rdf::Resource.new
bnode.rdf_subject
# => #<RDF::Node:0x3f967a58c1b8(_:g69915530281400)>
bnode << RDF::Statement.new(bnode.rdf_subject, RDF::DC.title, RDF::Literal('A blank node'))
bnode << RDF::Statement.new(bnode.rdf_subject, RDF::DC.subject, RDF::Literal('RDF'))
bnode.dump :ntriples
class SomethingDatastream < ActiveFedora::NtriplesRDFDatastream
property :contributor, predicate: RDF::URI('http://example.org/ns/contributor'), class_name: 'Contributor'
end
class Contributor < ActiveFedora::Rdf::Resource
configure type: RDF::URI('http://example.org/ns/Contributor')
property :name, predicate: RDF::FOAF.name
end
class Something < ActiveFedora::Base
@no-reply
no-reply / notes.md
Last active August 29, 2015 14:00
LDCX^5: Metadata Aggregation/Enhancement Notes

Metadata Session

Framing

Mark: DPLA harvests data in DC, MODS, MARCXML and site specific formats. This session is about that harvesting, mapping, and enhancement. What should an aggregation ingest stack look like?

@no-reply
no-reply / notes.txt
Last active August 29, 2015 14:01
Some Provenance Notes
@chrpr:
* We need field-instance level provenance for properties in an RDF model.
* We want to manage access controls based on this.
* This would allow us to have, for example, a batch-loaded dcterms:subject that is not editable, and have it co-exist on the same record with a manually created & fully editable dcterms:subject.
* I feel there should be a way to do this with activetriples, but in reviewing the repo & the gist, I'm not sure what would be best.
* I was considering an OAC inspired design, but don't like how that spec handles structured data in an annotation body (they basically say to record a bunch of extra serialized RDF as if it's a literal as the object of the oac:body tag...)
* I know this is possible with PROV-O, but figuring out how is proving painful.
* I thought about named graphs a bit, and am concerned about the number of different combinations we'd need & the complexity of the underlying graphs.