Giter VIP home page Giter VIP logo

bibcard's Introduction

BibCard

BibCard is a Ruby library for retrieving and assembling knowledge card information about the authors found in bibliographic data. It takes identifiers like Library of Congress Name Authority File (LCNAF) or VIAF URIs as input and crawls Linked Open Data sources on the web to assemble a Ruby objects or RDF serializations. This library will fetch data from:

The VIAF URI lies at the core of the BibCard::Person object because it acts as a hub to many other data sources on the Web. With the VIAF data in hand the other three sources listed above are "crawled" for more information about a given identity. Technically the data is requested by making one or more HTTP requests to each of the data sources' public SPARQL endpoints.

BibCard makes extensive use of the Spira library for RDF-to-object mapping. The result is that after assembling a micrograph of knowledge card data the client can work with simple code objects.

Installation

This gem is now in rubygems.

$ gem install bib_card

Alternatively, command line install:

$ git clone https://github.com/UW-Madison-Library/bibcard
$ cd bibcard
$ bundle install
$ gem build bib_card.gemspec
$ gem install bib_card-<VERSION-NUMBER>.gem

Usage

Instantiate a BibCard::Person

Given a Library of Congress Name Authority File or VIAF URI, instantiate a BibCard::Person and inspect the data.

Note: Every call to to BibCard.person() will make many calls to the public SPARQL endpoints for the sources cited above.

require 'bib_card'

lcnaf_uri = "http://id.loc.gov/authorities/names/n78086005"
person = BibCard.person(lcnaf_uri)

person.name(["en", "en-US"]) # => "Pablo Picasso"
person.birth_date   # => "1881-10-25"
person.death_date   # => "1973-04-09"

person.dbpedia_resource          # => <BibCard::DBPedia::Resource:70307318111440 @subject: http://dbpedia.org/resource/Pablo_Picasso>
person.dbpedia_resource.abstract # => "Pablo Ruiz y Picasso, also known as Pablo Picasso (/pɪˈkɑːsoʊ, -ˈkæsoʊ/; Spanish: [ˈpaβlo piˈkaso]; 25 October 1881 – 8 April 1973), was a Spanish painter..."

person.getty_subject                                                      # => <BibCard::Getty::Subject:70307331508400 @subject: http://vocab.getty.edu/ulan/500009666>
person.getty_subject.scope_note                                           # => <BibCard::Getty::ScopeNote:70307331409520 @subject: http://vocab.getty.edu/ulan/scopeNote/53649>
person.getty_subject.scope_note.value                                     # => "Long-lived and very influential Spanish artist, active in France. He dominated 20th-century European art. With Georges Braque, he is credited with inventing Cubism."
person.getty_subject.scope_note.sources                                   # => [<BibCard::Getty::Source:70307327167300 @subject: http://vocab.getty.edu/ulan/source/2100153925>, <BibCard::Getty::Source:70307327106100 @subject: http://vocab.getty.edu/ulan/source/2100156698>]
person.getty_subject.scope_note.sources.map {|source| source.short_title} # => ["LCNAF Library of Congress Name Authority File  [n.d.]", "Grove Dictionary of Art online (1999-2002)"]

Fetch Raw Data for a BibCard::Person

A BibCard knowledge/info card is generated from many different sources, which is inherently slow. You can also retrieve person data as a serialized string of RDF n-triples. The raw data is available so that it can be cached locally. Once the data is cached you can load a Spira repository and instantiate a BibCard::Person object.

require 'bib_card'

lcnaf_uri = "http://id.loc.gov/authorities/names/n78086005"
data = BibCard.person_data(lcnaf_uri)
puts data

# <http://viaf.org/viaf/15873> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
# <http://viaf.org/viaf/15873> <http://schema.org/deathDate> "1973-04-09" .
# <http://viaf.org/viaf/15873> <http://schema.org/sameAs> <http://id.loc.gov/authorities/names/n78086005> .
# ...

#### cache the serialized data ####

Spira.repository = RDF::Repository.new.from_ntriples(data)
viaf_uri         = Spira.repository.query(predicate: BibCard::SCHEMA_SAME_AS, object: RDF::URI.new(lcnaf_uri)).first.subject
person           = viaf_uri.as(BibCard::Person)

person              # => <BibCard::Person:70307327106900 @subject: http://viaf.org/viaf/15873>
person.name(["en", "en-US"]) # => "Pablo Picasso"

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/UW-Madison-Library/bibcard. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

bibcard's People

Contributors

nacengineer avatar davidjlee avatar steve-meyer avatar

Stargazers

Zaki Mughal [sivoais] avatar Jodi Schneider avatar David Fox avatar Jessica Kruppa avatar Dan Michael O. Heggø avatar Cory Lown avatar Aidan Sawyer avatar  avatar Mike Kanning avatar Ettore Rizza avatar  avatar Noah Geraci avatar Holly Tomren avatar Dan Scott avatar Anna Malantonio avatar Jenn Colt avatar Jen Short avatar Dazhi Jiao avatar Steve Henry avatar Martin Patrick avatar Charles Ledvina avatar Erik Paulson avatar Marc d'Avernas avatar Mark Baggett avatar Tod Robbins avatar Konstantin Baierer avatar raffaele messuti avatar Ryan Johnson avatar María A. Matienzo avatar Jason Ronallo avatar Goran Halusa avatar Tim Thompson avatar Karen Coombs avatar

Watchers

James Cloos avatar  avatar Aidan Sawyer avatar  avatar Marc d'Avernas avatar Martin Patrick avatar Dazhi Jiao avatar  avatar

Forkers

jimfhahn

bibcard's Issues

Release to Rubygems

Hi there. Great library- thanks! It would be very helpful to have this in Rubygems to ease installation. I had to go through a few hoops to deploy this as a serverless API in AWS.

Any plans to do so in the near future?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.