-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfaculty_wos_search_helper.rb
53 lines (43 loc) · 1.52 KB
/
faculty_wos_search_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# helper method used by the faculty_wos_search report
def enumerate_results(result_xml_doc,countries_count,author_countries_count,organizations_count,author_organizations_count,search_countries,search_orgs,restrict_to_organizations)
begin
puts "........collecting pubs"
pubs = Nokogiri::XML(result_xml_doc.xpath("//records")[0].content).remove_namespaces!.xpath('//records/REC')
if search_countries
puts "........looking for countries"
countries = pubs.search('addresses//country').map {|address| address.content.titleize}
end
if search_orgs
puts "........looking for organizations"
organizations = pubs.search("addresses//organization[@pref='Y']").map do |organization|
org_name = organization.content
unless restrict_to_organizations.blank?
org_name if restrict_to_organizations.include?(org_name)
else
org_name
end
end
organizations.reject!(&:blank?)
end
if search_countries
puts "........enumerating countries"
countries.each do |country|
countries_count[country] += 1
author_countries_count[country] += 1
end
end
if search_orgs
puts "........enumerating organizations"
organizations.each do |organization|
organizations_count[organization] += 1
author_organizations_count[organization] += 1
end
end
return pubs.size
rescue
return 0
end
end
def quote_wrap(terms)
terms.compact_blank.uniq.map { |x| "\"#{x.delete('"')}\"" }
end