lib/marc2linkeddata/parseMarcAuthority.rb
# Create triples for various kinds of LOC authority.
# This method relies on RDF data retrieval.
Create triples for various kinds of LOC authority.
This method relies on RDF data retrieval.
Create triples for various kinds of LOC authority . This method relies on RDF data retrieval .
def parse_auth_name_rdf
      @@config.logger.warn "#{@loc.iri} DEPRECATED" if @loc.deprecated?
      name = ''
      if @loc.person?
        name = @loc.label || field100[:name]
        graph_type_person(@lib.rdf_uri)
        if @@config.get_viaf && ! @viaf.nil?
          @viaf.family_names.each do |n|
            ln = RDF::Literal.new(n)
            @graph.insert RDF::Statement(@lib.rdf_uri, RDF::FOAF.familyName, ln) if @@config.use_foaf
            @graph.insert RDF::Statement(@lib.rdf_uri, RDF::SCHEMA.familyName, ln) if @@config.use_schema
          end
          @viaf.given_names.each do |n|
            fn = RDF::Literal.new(n)
            @graph.insert RDF::Statement(@lib.rdf_uri, RDF::FOAF.firstName, fn) if @@config.use_foaf
            @graph.insert RDF::Statement(@lib.rdf_uri, RDF::SCHEMA.givenName, fn) if @@config.use_schema
          end
        end
      elsif @loc.name_title?
        name = @loc.label || field100[:name]
        graph_insert_type(@lib.rdf_uri, RDF::URI.new('http://www.loc.gov/mads/rdf/v1#NameTitle'))
      elsif @loc.corporation?
        name = @loc.label || field110[:name]
        graph_type_organization(@lib.rdf_uri)
      elsif @loc.conference?
        name = @loc.label || [field111[:name],field111[:date],field111[:city]].join('')
        graph_insert_type(@lib.rdf_uri, RDF::SCHEMA.event)
      elsif @loc.geographic?
        name = @loc.label || field151[:name]
        graph_insert_type(@lib.rdf_uri, RDF::SCHEMA.Place)
      elsif @loc.uniform_title?
        name = field130[:title]  
        graph_insert_type(@lib.rdf_uri, RDF::URI.new('http://www.loc.gov/mads/rdf/v1#Title'))
        graph_insert_type(@lib.rdf_uri, RDF::SCHEMA.title)
      else
        binding.pry if @@config.debug
        name = @loc.label || ''
        graph_type_agent(@lib.rdf_uri)
      end
      if name != ''
        name = RDF::Literal.new(name)
        graph_insert_name(@lib.rdf_uri, name)
      end
    end
def parse_auth_name_rdf @@config . logger . warn "#{@loc.iri} DEPRECATED" if @loc . deprecated? name = '' if @loc . person? name = @loc . label || field100 [ :name ] graph_type_person ( @lib . rdf_uri ) if @@config . get_viaf && ! @viaf . nil? @viaf . family_names . each do | n | ln = RDF :: Literal . new ( n ) @graph . insert RDF :: Statement ( @lib . rdf_uri , RDF :: FOAF . familyName , ln ) if @@config . use_foaf @graph . insert RDF :: Statement ( @lib . rdf_uri , RDF :: SCHEMA . familyName , ln ) if @@config . use_schema end @viaf . given_names . each do | n | fn = RDF :: Literal . new ( n ) @graph . insert RDF :: Statement ( @lib . rdf_uri , RDF :: FOAF . firstName , fn ) if @@config . use_foaf @graph . insert RDF :: Statement ( @lib . rdf_uri , RDF :: SCHEMA . givenName , fn ) if @@config . use_schema end end elsif @loc . name_title? name = @loc . label || field100 [ :name ] graph_insert_type ( @lib . rdf_uri , RDF :: URI . new ( 'http://www.loc.gov/mads/rdf/v1#NameTitle' ) ) elsif @loc . corporation? name = @loc . label || field110 [ :name ] graph_type_organization ( @lib . rdf_uri ) elsif @loc . conference? name = @loc . label || [ field111 [ :name ] , field111 [ :date ] , field111 [ :city ] ] . join ( '' ) graph_insert_type ( @lib . rdf_uri , RDF :: SCHEMA . event ) elsif @loc . geographic? name = @loc . label || field151 [ :name ] graph_insert_type ( @lib . rdf_uri , RDF :: SCHEMA . Place ) elsif @loc . uniform_title? name = field130 [ :title ] graph_insert_type ( @lib . rdf_uri , RDF :: URI . new ( 'http://www.loc.gov/mads/rdf/v1#Title' ) ) graph_insert_type ( @lib . rdf_uri , RDF :: SCHEMA . title ) else binding . pry if @@config . debug name = @loc . label || '' graph_type_agent ( @lib . rdf_uri ) end if name != '' name = RDF :: Literal . new ( name ) graph_insert_name ( @lib . rdf_uri , name ) end end
Create triples for various kinds of LOC authority.
Create triples for various kinds of LOC authority .
# VIAF extracts first and last name, try to use them. Note # that VIAF uses schema:name, schema:givenName, and schema:familyName. # ln = URI.encode(n) # TODO: try to get a language type, if VIAF provide it. # name = RDF::Literal.new(n, :language => :en) # fn = URI.encode(n) # TODO: try to get a language type, if VIAF provide it. # name = RDF::Literal.new(n, :language => :en) # e.g. http://id.loc.gov/authorities/names/n79044934 # http://viaf.org/viaf/182251325/rdf.xml # e.g. http://id.loc.gov/authorities/names/n79044866 # e.g. http://id.loc.gov/authorities/names/n79045127 # use 'name' for code below, although it's a title # TODO: find out what type this is.