Skip to content

Instantly share code, notes, and snippets.

Avatar
🧊

tamsin johnson no-reply

🧊
  • UC Santa Barbara Library
  • United States
View GitHub Profile
@no-reply
no-reply / bag_import_error.rb
Created Aug 5, 2013
Blobs of bagit-for-hydra stuff
View bag_import_error.rb
module Hybag
class BagImportError < StandardError
end
end
@no-reply
no-reply / bag_import_error.rb
Created Aug 5, 2013
Blobs of bagit-for-hydra stuff
View bag_import_error.rb
module Hybag
class BagImportError < StandardError
end
end
@no-reply
no-reply / nt2bag.rb
Created Aug 6, 2013
Some ugly Ruby for stuffing processed ContentDM metadata into bags.
View nt2bag.rb
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 Dec 26, 2015
Oregon Digital RDF
View RDF Samples
<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 Jul 12, 2017
RDF Resources in OregonDigital
View oregon_rdf_demo.rb
# 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 Jan 4, 2016
Using Vocabulary Loader
View vocabs.rb
# 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 Aug 29, 2015
A Demo of ActiveFedora::Rdf in 7.x
View rdf_demo.rb
# 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
View something_rdf.rb
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 Aug 29, 2015
LDCX^5: Metadata Aggregation/Enhancement Notes
View notes.md

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 Aug 29, 2015
Some Provenance Notes
View notes.txt
@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.