Class: Marc2LinkedData::SparqlPubmed

Inherits:
Sparql
  • Object
show all
Defined in:
lib/marc2linkeddata/sparql_pubmed.rb

Instance Attribute Summary

Attributes inherited from Sparql

#sparql

Instance Method Summary collapse

Constructor Details

#initializeSparqlPubmed

Returns a new instance of SparqlPubmed.



7
8
9
10
# File 'lib/marc2linkeddata/sparql_pubmed.rb', line 7

def initialize
  # config = Marc2LinkedData.configuration
  super('http://pubmed.bio2rdf.org/sparql')
end

Instance Method Details

#find_author(last_name, first_name = nil, middle_initial = nil) ⇒ Object

Note, might have to use first name initial for matching.



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/marc2linkeddata/sparql_pubmed.rb', line 28

def find_author(last_name, first_name=nil, middle_initial=nil)
  q  = 'SELECT DISTINCT ?author ?fn WHERE { '
  q += '?author a <http://bio2rdf.org/pubmed_vocabulary:Author> . '
  q += '?author <http://bio2rdf.org/pubmed_vocabulary:fore_name> ?fn . '
  q += "?author <http://bio2rdf.org/pubmed_vocabulary:last_name> \"#{last_name}\"^^<http://www.w3.org/2001/XMLSchema#string> . "
  q += '}'
  result = @sparql.query(q)
  result.each_solution do |s|
    # match on first_name? or initials?
    puts s.inspect
  end
  binding.pry
end