forked from berkmancenter/geosearch_solr_prep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibcloud_csv_template.csv.erb
45 lines (45 loc) · 3.14 KB
/
libcloud_csv_template.csv.erb
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
<% libcloud_fields = [
'id', 'title', 'title_sort', 'title_link_friendly', 'sub_title', 'creator',
'publisher', 'pub_location', 'pub_date', 'pub_date_numeric', 'format', 'language',
'pages', 'pages_numeric', 'height', 'height_numeric', 'lcsh', 'note',
'toc', 'call_num', 'id_inst', 'id_isbn', 'id_lccn', 'id_oclc',
'rsrc_key', 'rsrc_value', 'wp_categories', 'online_avail', 'holding_libs', 'ut_id',
'ut_count', 'loc_call_num_sort_order', 'loc_call_num_subject', 'url', 'data_source', 'dataset_tag',
'shelfrank', 'score_checkouts_undergrad', 'score_checkouts_grad', 'score_checkouts_fac', 'score_reserves', 'score_recalls',
'score_course_texts', 'score_holding_libs', 'score_extra_copies', 'score_total', 'title_exact', 'creator_exact',
'lcsh_exact', 'wp_categories_exact', 'title_keyword', 'creator_keyword', 'subject_keyword', 'note_keyword', 'keyword'
]
%><% docs.each do |doc| %><% if doc['geotags'] %><% doc['geotags'].each do |geotag| %><%= doc['id'] %>-<%= geotag['anchor_start'] %>
<%= "#{geotag['disjuncts'][0]['latitude']},#{geotag['disjuncts'][0]['longitude']}" %>
<%= "#{geotag['disjuncts'][0]['latitude']},#{geotag['disjuncts'][0]['longitude']}" %>
<% if geotag['disjuncts'][1] %><%= "#{geotag['disjuncts'][1]['latitude']},#{geotag['disjuncts'][1]['longitude']}" %>
<% else %>
<% end %><% if geotag['disjuncts'][2] %><%= "#{geotag['disjuncts'][2]['latitude']},#{geotag['disjuncts'][2]['longitude']}" %>
<% else %>
<% end %><% libcloud_fields.each do |field| %><% if doc[field].kind_of? Array %><%= doc[field].map{|field_value| if field_value.respond_to? 'clean' then field_value.clean else field_value end}.join('|||') %><% elsif doc[field] %><%= if doc[field].respond_to? 'clean' then doc[field].clean else doc[field] end %><% end %>
<% end %><%= geotag['confidence'] %>
<%= geotag['in_field'].gsub('.','_') %>
<%= geotag['anchor'].clean %>
<% 3.times do |i| %><% if geotag['disjuncts'][i] then disjunct = geotag['disjuncts'][i] %><%= disjunct['weight'] %>
<%= disjunct['name'] %>
<% if disjunct['country'] %><%= disjunct['country'] %>
<% else %>
<% end %><% if disjunct['country_name'] %><%= disjunct['country_name'] %>
<% else %>
<% end %><% if disjunct['country_confidence'] %><%= disjunct['country_confidence'] %>
<% else %>
<% end %><% if disjunct['province'] %><%= disjunct['province'] %>
<% else %>
<% end %><% if disjunct['province_name'] %><%= disjunct['province_name'] %>
<% else %>
<% end %><% if disjunct['province_confidence'] %><%= disjunct['province_confidence'] %>
<% else %>
<% end %><%= disjunct['latitude'] %>
<%= disjunct['longitude'] %>
<% [12, 10, 8, 6, 4, 3, 2].each do |precision| %><%= disjunct["geo_hash"][0, precision] %>
<% end %><% else %><%= "\n"*17 %>
<% end %><% end %><doc-end>
<% end %><% else %><%= doc['id'] %><%= "\n"*4 %>
<% libcloud_fields.each do |field| %><% if doc[field].kind_of? Array %><%= doc[field].map{|field_value| if field_value.respond_to? 'clean' then field_value.clean else field_value end}.join('|||') %><% elsif doc[field] %><%= if doc[field].respond_to? 'clean' then doc[field].clean else doc[field] end %><% end %>
<% end %><%= "\n"*17*3 %><doc-end>
<% end %><% end %>