Class: Scopus::XMLResponse::Abstractsretrievalresponse
- Inherits:
-
XMLResponseGeneric
- Object
- XMLResponseGeneric
- Scopus::XMLResponse::Abstractsretrievalresponse
- Defined in:
- lib/scopus/xml_response/abstract_retrieval_response.rb
Constant Summary collapse
- NA_AFFILIATION =
"NAFD:**NA**"
- NA_AFFILIATION_NAME =
"__No affiliation__"
Instance Attribute Summary collapse
-
#abstract ⇒ Object
readonly
Returns the value of attribute abstract.
-
#affiliations ⇒ Object
readonly
Returns the value of attribute affiliations.
-
#author_groups ⇒ Object
readonly
Returns the value of attribute author_groups.
-
#author_keywords ⇒ Object
readonly
Returns the value of attribute author_keywords.
-
#authors ⇒ Object
readonly
Returns the value of attribute authors.
-
#book_title ⇒ Object
readonly
Returns the value of attribute book_title.
-
#cited_by_count ⇒ Object
readonly
Returns the value of attribute cited_by_count.
-
#doi ⇒ Object
readonly
Returns the value of attribute doi.
-
#eid ⇒ Object
readonly
Returns the value of attribute eid.
-
#ending_page ⇒ Object
readonly
Returns the value of attribute ending_page.
-
#issue ⇒ Object
readonly
Returns the value of attribute issue.
-
#journal ⇒ Object
readonly
Returns the value of attribute journal.
-
#scopus_id ⇒ Object
readonly
Returns the value of attribute scopus_id.
-
#starting_page ⇒ Object
readonly
Returns the value of attribute starting_page.
-
#subject_areas ⇒ Object
readonly
Returns the value of attribute subject_areas.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#type_code ⇒ Object
readonly
Returns the value of attribute type_code.
-
#volume ⇒ Object
readonly
Returns the value of attribute volume.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #add_no_affiliation_case(auid) ⇒ Object
- #add_unidentified_affilitations ⇒ Object
- #get_affiliation_data(aff) ⇒ Object
- #get_affiliation_id(aff) ⇒ Object
-
#get_id_affiliation(name, city, country) ⇒ Object
Some affiliations doesn't have an id.
- #inspect ⇒ Object
- #process ⇒ Object
- #process_affiliations ⇒ Object
-
#process_author_groups ⇒ Object
Author groups gives us information about the authors groups as appears on the head.
- #process_authors ⇒ Object
- #process_basic_metadata ⇒ Object
- #process_taxonomy ⇒ Object
-
#search_affiliation(afid) ⇒ Object
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.
- #search_affiliation_country(id) ⇒ Object
-
#search_doi ⇒ Object
We have to find doi on.
Constructor Details
This class inherits a constructor from Scopus::XMLResponse::XMLResponseGeneric
Instance Attribute Details
#abstract ⇒ Object (readonly)
Returns the value of attribute abstract.
48 49 50 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 48 def abstract @abstract end |
#affiliations ⇒ Object (readonly)
Returns the value of attribute affiliations.
47 48 49 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 47 def affiliations @affiliations end |
#author_groups ⇒ Object (readonly)
Returns the value of attribute author_groups.
52 53 54 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 52 def @author_groups end |
#author_keywords ⇒ Object (readonly)
Returns the value of attribute author_keywords.
50 51 52 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 50 def @author_keywords end |
#authors ⇒ Object (readonly)
Returns the value of attribute authors.
41 42 43 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 41 def @authors end |
#book_title ⇒ Object (readonly)
Returns the value of attribute book_title.
51 52 53 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 51 def book_title @book_title end |
#cited_by_count ⇒ Object (readonly)
Returns the value of attribute cited_by_count.
34 35 36 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 34 def cited_by_count @cited_by_count end |
#doi ⇒ Object (readonly)
Returns the value of attribute doi.
46 47 48 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 46 def doi @doi end |
#eid ⇒ Object (readonly)
Returns the value of attribute eid.
36 37 38 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 36 def eid @eid end |
#ending_page ⇒ Object (readonly)
Returns the value of attribute ending_page.
45 46 47 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 45 def ending_page @ending_page end |
#issue ⇒ Object (readonly)
Returns the value of attribute issue.
43 44 45 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 43 def issue @issue end |
#journal ⇒ Object (readonly)
Returns the value of attribute journal.
40 41 42 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 40 def journal @journal end |
#scopus_id ⇒ Object (readonly)
Returns the value of attribute scopus_id.
33 34 35 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 33 def scopus_id @scopus_id end |
#starting_page ⇒ Object (readonly)
Returns the value of attribute starting_page.
44 45 46 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 44 def starting_page @starting_page end |
#subject_areas ⇒ Object (readonly)
Returns the value of attribute subject_areas.
49 50 51 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 49 def subject_areas @subject_areas end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
35 36 37 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 35 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
38 39 40 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 38 def type @type end |
#type_code ⇒ Object (readonly)
Returns the value of attribute type_code.
37 38 39 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 37 def type_code @type_code end |
#volume ⇒ Object (readonly)
Returns the value of attribute volume.
42 43 44 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 42 def volume @volume end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
39 40 41 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 39 def year @year end |
Instance Method Details
#add_no_affiliation_case(auid) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 154 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 ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 138 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) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 165 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) ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 96 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) ⇒ Object
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
135 136 137 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 135 def get_id_affiliation(name,city,country) "NS:"+Digest::MD5.hexdigest("#{name}|#{city}|#{country}") end |
#inspect ⇒ Object
53 54 55 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 53 def inspect "#<#{self.class}:#{self.object_id} @title=#{@title} @journal=#{@journal} @authors=[#{@authors.keys.join(",")}]>" end |
#process ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 56 def process @authors={} @affiliations={} @author_keywords=[] @subject_areas=[] @author_groups=[] process_taxonomy process_affiliations end |
#process_affiliations ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 111 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_author_groups ⇒ Object
Author groups gives us information about the authors groups as appears on the head. Could be useful to retrieve information about missing affilitations Author-groups with authors duplicated are eliminated
186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 186 def =xml.xpath("//bibrecord/head/author-group").map do |ag| (ag) end #authors_list= [] @author_groups= # @author_groups=[] # author_groups_temp.each do |ag| # @author_groups.push(ag) unless ag[:authors].any? {|author| authors_list.include? author} # authors_list=authors_list | ag[:authors] # end end |
#process_authors ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 224 def xml.xpath("//xmlns:authors/xmlns:author").each do |x| auid=x.attribute("auid").value seq=x.attribute("seq").value initials =process_path(x, "xmlns:preferred-name/ce:initials") indexed_name = process_path(x, "xmlns:preferred-name/ce:indexed-name") given_name =process_path(x, "xmlns:preferred-name/ce:given-name") surname=process_path(x, "xmlns:preferred-name/ce:surname") affiliation=nil affiliation_node=x.xpath("xmlns:affiliation") if affiliation_node.length==1 affiliation=affiliation_node[0].attribute("id").text if !affiliation.nil? and @affiliations[affiliation].nil? @affiliations[affiliation]=search_affiliation(affiliation) end elsif affiliation_node.length>1 affiliation=affiliation_node.map{|af| af.attribute("id").text }.uniq affiliation.each do |af| if !af.nil? and @affiliations[af].nil? @affiliations[af]=search_affiliation(af) end end else # Must search in author-groups for affilitation res=@author_groups.find{|ag| ag[:authors].include? auid } if res affiliation=res[:affiliation] end if affiliation.nil? # Affiliation shouldn't be nil. We create a custom affiliation for this cases affiliation=add_no_affiliation_case(auid) end # end #p "#{name} #{apellido}" @authors[auid]={ :auid => auid, :seq => seq, :initials => initials, :indexed_name => indexed_name, :given_name => given_name, :surname => surname, :email => nil, :affiliation => affiliation } end # Searching for authors e-mails xml.xpath("//bibrecord//head//author-group/author//ce:e-address[@type='email']").each do |email| auid=email.parent.attribute("auid").value @authors[auid][:email]=email.text end end |
#process_basic_metadata ⇒ Object
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 303 def @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 ⇒ Object
289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 289 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) ⇒ Object
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
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 75 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) ⇒ Object
107 108 109 110 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 107 def search_affiliation_country(id) return nil if id.nil? process_path(xml, "//affiliation[@afid='#{id}']/country") end |
#search_doi ⇒ Object
We have to find doi on
89 90 91 92 93 94 |
# File 'lib/scopus/xml_response/abstract_retrieval_response.rb', line 89 def search_doi if xml.at_xpath("//source").text=~/^\s*http:\/\/dx\.doi\.org\/([^\s]+)/ return $1 end end |