class ElsevierApi::XMLResponse::Abstractsretrievalresponse
Constants
- NA_AFFILIATION
- NA_AFFILIATION_NAME
Attributes
abstract[R]
affiliations[R]
book_title[R]
cited_by_count[R]
doi[R]
eid[R]
ending_page[R]
issue[R]
journal[R]
scopus_id[R]
starting_page[R]
subject_areas[R]
title[R]
type[R]
type_code[R]
volume[R]
year[R]
Public Instance Methods
add_no_affiliation_case(auid)
click to toggle source
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 158 def add_no_affiliation_case(auid) id=NA_AFFILIATION+":"+Digest::MD5.hexdigest("#{@scopus_id}|#{auid}") @affiliations[id]={ :id => id, :name => "#{@scopus_id}|#{auid}", :city => "", :country => "NO_COUNTRY", :type=>:non_scopus } id end
add_unidentified_affilitations()
click to toggle source
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 142 def add_unidentified_affilitations xml.xpath("//bibrecord/head/author-group/affiliation").each do |aff| next if aff.attribute("afid") city, country, id, name = get_affiliation_data(aff) next if (name=="" and city=="" and country=="") @affiliations[id]={ :id => id, :name => name, :city => city, :country => country, :type=>:non_scopus } end end
get_affiliation_data(aff)
click to toggle source
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 169 def get_affiliation_data(aff) organization=aff.xpath("organization").map { |e| e.text }.join(";") address=aff.xpath("address-part").map { |e| e.text }.join(";") name= organization!="" ? organization : address city_only=aff.xpath("city").text city_part=aff.xpath("city-group").text city= city_only!="" ? city_only : city_part country=aff.xpath("country").text name="UNKOWN ORG FOR #{@scopus_id} ARTICLE" if name=="" country="NO_COUNTRY" if country=="" id=get_id_affiliation(name,city,country) return city, country, id, name end
get_affiliation_id(aff)
click to toggle source
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 100 def get_affiliation_id(aff) if aff.nil? nil elsif id=aff.attribute('afid') id.value else city, country, id, name = get_affiliation_data(aff) id end end
get_id_affiliation(name,city,country)
click to toggle source
Some affiliations doesn't have an id. We could create it hashing the name and the country on unidentified filliations on head tag The process only add the affiliation if name is not nil
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 139 def get_id_affiliation(name,city,country) "NS:"+Digest::MD5.hexdigest("#{name}|#{city}|#{country}") end
inspect()
click to toggle source
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 57 def inspect "#<#{self.class}:#{self.object_id} @title=#{@title} @journal=#{@journal} @authors=[#{@authors.keys.join(",")}]>" end
process()
click to toggle source
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 60 def process @authors={} @affiliations={} @author_keywords=[] @subject_areas=[] @author_groups=[] process_basic_metadata process_taxonomy process_affiliations process_author_groups process_authors end
process_affiliations()
click to toggle source
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 115 def process_affiliations xml.xpath("/xmlns:abstracts-retrieval-response/xmlns:affiliation").each do |x| id=x.attribute("id").nil? ? "" : x.attribute("id").value next if id=="" name=process_path(x, "xmlns:affilname") city=process_path(x, "xmlns:affiliation-city") country=process_path(x, "xmlns:affiliation-country") country=search_affiliation_country(id) if (country=="") @affiliations[id]={ :id => id, :name => name, :city => city, :country => country, :type=>:scopus } end add_unidentified_affilitations end
process_basic_metadata()
click to toggle source
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 307 def process_basic_metadata @scopus_id = process_path(xml, "//dc:identifier") @title = process_path(xml, "//dc:title") @doi = process_path(xml, "//prism:doi") @doi||=search_doi @eid = process_path(xml, "//xmlns:eid") @type_code = process_path(xml, "//xmlns:srctype") @cited_by_count = process_path(xml,"//xmlns:citedby-count").to_i @type = process_path(xml, "//prism:aggregationType").downcase.to_sym if @type_code=="j" or @type_code=="p" @journal =process_path(xml, "//prism:publicationName") @volume =process_path(xml, "//prism:volume") @issue =process_path(xml, "//prism:issueIdentifier") elsif @type_code=="b" @book_title =process_path(xml, "//prism:publicationName") end @starting_page =process_path(xml, "//prism:startingPage") @ending_page =process_path(xml, "//prism:endingPage") @year =process_path(xml, "//year") @abstract =process_path(xml, "//dc:description/xmlns:abstract[@xml:lang='eng']/ce:para") @abstract ||=process_path(xml, "//abstract/ce:para") end
process_taxonomy()
click to toggle source
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 293 def process_taxonomy xml.xpath("//xmlns:authkeywords/xmlns:author-keyword").each do |x| @author_keywords.push(x.text) end xml.xpath("//xmlns:subject-areas/xmlns:subject-area").each do |x| @subject_areas.push( {:abbrev => x.attribute("abbrev").value, :code => x.attribute("code").value.to_i, :name => x.text } ) end end
search_affiliation(afid)
click to toggle source
We can't find the affiliation the ussual way we have to improvise Given the afid, we search on every <affiliation> tag until we find the desired one
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 79 def search_affiliation(afid) x=xml.at_xpath("//affiliation[@afid=\"#{afid}\"]") if !x raise "I can't find affiliation #{afid}" else name=x.xpath("organization").map { |e| e.text }.join(";") city=process_path(xml, "//affiliation[@afid=\"#{afid}\"]/city-group") country=process_path(xml, "//affiliation[@afid=\"#{afid}\"]/country") country||=x.attribute("country").value end {:id => afid, :name => name, :city => city, :country => country,:type=>:scopus} end
search_affiliation_country(id)
click to toggle source
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 111 def search_affiliation_country(id) return nil if id.nil? process_path(xml, "//affiliation[@afid='#{id}']/country") end
search_doi()
click to toggle source
We have to find doi on
# File lib/elsevier_api/xml_response/abstract_retrieval_response.rb, line 93 def search_doi if xml.at_xpath("//source").text=~/^\s*http:\/\/dx\.doi\.org\/([^\s]+)/ return $1 end end