bpl_enrich 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f724458c14578154f1ec766c46a67d25b2df49c2
4
- data.tar.gz: 3b922f75a5646e7e856aa6746c493a7b8982f67b
3
+ metadata.gz: a4e7129fbd3d62ae913e1132eefc46f71bb0d873
4
+ data.tar.gz: 87aa5ec281547a66381f5be02591f092e7ab3bd2
5
5
  SHA512:
6
- metadata.gz: 124289eebef362c4332d5e7fdd57baff97c87f125a81a9374ef1f26826debabd15afe62b234c91487b5e944ea1a128e2b47112c14bff6aaff7c5fdee9ffcebfa
7
- data.tar.gz: 906c244fe8a40ed92add65908ad2fe390723858738fe1ef83e23bafb953677c427d1be1db99c974c3cdb4e95ebc3542e2723e867a58d549cb085faaccecb44d0
6
+ metadata.gz: 9b49f75f24a1c3943b6832f573c207078dcb1310a13fdee67ca5f7c6f60dabc9b9ca6425da2c2d725681bc1ea9c3576d8f999ac429df3d0020cf272a01677377
7
+ data.tar.gz: 552094f260de1fab3e39513f22766cde03323d9b045b68b74be9437cc98df5895d21a5f3dc44358e844a4c5dcd4571c7d93d1cc6c23c3e8fc6d62fabd16e0e97
@@ -1,6 +1,28 @@
1
1
  module BplEnrich
2
2
  class Authorities
3
3
 
4
+ # return the full URI for a given authority (LCSH, NAF, etc)
5
+ def self.authority_uri(auth)
6
+ case auth
7
+ when 'lctgm'
8
+ 'http://id.loc.gov/vocabulary/graphicMaterials'
9
+ when 'gmgpc'
10
+ 'http://id.loc.gov/vocabulary/graphicMaterials'
11
+ when 'lcsh'
12
+ 'http://id.loc.gov/authorities/subjects'
13
+ when 'aat'
14
+ 'http://vocab.getty.edu/aat'
15
+ when 'naf'
16
+ 'http://id.loc.gov/authorities/names'
17
+ when 'marcgt'
18
+ 'http://id.loc.gov/vocabulary/genreFormSchemes/marcgt'
19
+ when 'homosaurus'
20
+ 'http://homosaurus.org/terms'
21
+ else
22
+ ''
23
+ end
24
+ end
25
+
4
26
  def self.parse_language(language_value)
5
27
  return_hash = {}
6
28
  authority_check = Qa::Authorities::Loc.subauthority_for('iso639-2')
@@ -48,7 +70,7 @@ module BplEnrich
48
70
  authority_result = authority_check.search(URI.escape(role_value))
49
71
  if authority_result.present?
50
72
 
51
- authority_result = authority_result.select{|hash| hash['label'].downcase == role_value.downcase}
73
+ authority_result = authority_result.select{|hash| hash['label'].downcase == role_value.singularize.downcase}
52
74
  if authority_result.present?
53
75
  #Remove the word and any other characters around it. $ means the end of the line.
54
76
  #
@@ -63,7 +85,7 @@ module BplEnrich
63
85
  authority_result = authority_check.search(URI.escape(role_value))
64
86
  if authority_result.present? && return_hash[:uri].blank?
65
87
 
66
- authority_result = authority_result.select{|hash| hash['label'].downcase == role_value.downcase}
88
+ authority_result = authority_result.select{|hash| hash['label'].downcase == role_value.singularize.downcase}
67
89
  if authority_result.present?
68
90
  #Remove the word and any other characters around it. $ means the end of the line.
69
91
  return_hash[:name] = name.sub(/[\(\"\', ]*\w+[ \),\"\']*/, '').gsub(/^[ ]*\:/, '').strip
@@ -88,8 +88,8 @@ module BplEnrich
88
88
  # deal with date strings with 2 4-digit year values separately
89
89
  if value.scan(/\d\d\d\d/).length == 2
90
90
 
91
- # convert weird span indicators ('or','and','||'), remove extraneous text
92
- value = value.gsub(/(or|and|\|\|)/,'-').gsub(/[A-Za-z\?\s]/,'')
91
+ # convert weird span indicators ('or','and','||', 'to'), remove extraneous text
92
+ value = value.gsub(/(or|and|to|\|\|)/,'-').gsub(/[A-Za-z\?\s]/,'')
93
93
 
94
94
  if value.match(/\A[12][\d]{3}-[01][\d]-[0123][\d][\/-][12][\d]{3}-[01][\d]-[0123][\d]\z/) #1939-04-22/1941-11-30 or 1939-04-22-1941-11-30
95
95
  date_data_range_start = value[0..9]
@@ -1,3 +1,3 @@
1
1
  module BplEnrich
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -92,6 +92,13 @@ class DatesTest < ActiveSupport::TestCase
92
92
  assert_equal '1933-12-31', result[:date_range][:end]
93
93
  assert_nil result[:date_qualifier]
94
94
  assert_nil result[:date_note]
95
+
96
+ result = BplEnrich::Dates.standardize('May 1996 to June 1996')
97
+ assert_nil result[:single_date]
98
+ assert_equal '1996-05', result[:date_range][:start]
99
+ assert_equal '1996-06', result[:date_range][:end]
100
+ assert_nil result[:date_qualifier]
101
+ assert_nil result[:date_note]
95
102
  end
96
103
 
97
104
 
@@ -1,138 +1,3 @@
1
-  (0.0ms) begin transaction
2
- --------------------------------
3
- LCSHTest: test_lcsh_standardizer
4
- --------------------------------
5
-  (0.0ms) rollback transaction
6
-  (0.0ms) begin transaction
7
- ---------------------------------
8
- DatesTest: test_date_standardizer
9
- ---------------------------------
10
-  (0.0ms) rollback transaction
11
-  (0.0ms) begin transaction
12
- ------------------------------------
13
- AuthoritiesTest: test_parse_language
14
- ------------------------------------
15
-  (0.1ms) rollback transaction
16
-  (0.0ms) begin transaction
17
- -----------------------------------------
18
- AuthoritiesTest: test_parse_name_for_role
19
- -----------------------------------------
20
-  (0.1ms) rollback transaction
21
-  (0.0ms) begin transaction
22
- --------------------------------
23
- AuthoritiesTest: test_parse_role
24
- --------------------------------
25
-  (0.1ms) rollback transaction
26
-  (0.0ms) begin transaction
27
- -------------------------------
28
- BplEnrichTest: test_strip_value
29
- -------------------------------
30
-  (0.0ms) rollback transaction
31
-  (0.0ms) begin transaction
32
- ---------------------------------
33
- DatesTest: test_date_standardizer
34
- ---------------------------------
35
-  (0.0ms) rollback transaction
36
-  (0.0ms) begin transaction
37
- --------------------------------
38
- LCSHTest: test_lcsh_standardizer
39
- --------------------------------
40
-  (0.0ms) rollback transaction
41
-  (0.0ms) begin transaction
42
- -------------------------------
43
- BplEnrichTest: test_strip_value
44
- -------------------------------
45
-  (0.0ms) rollback transaction
46
-  (0.0ms) begin transaction
47
- ------------------------------------
48
- AuthoritiesTest: test_parse_language
49
- ------------------------------------
50
-  (0.1ms) rollback transaction
51
-  (0.0ms) begin transaction
52
- -----------------------------------------
53
- AuthoritiesTest: test_parse_name_for_role
54
- -----------------------------------------
55
-  (0.1ms) rollback transaction
56
-  (0.0ms) begin transaction
57
- --------------------------------
58
- AuthoritiesTest: test_parse_role
59
- --------------------------------
60
-  (0.1ms) rollback transaction
61
-  (0.0ms) begin transaction
62
- -------------------------------
63
- BplEnrichTest: test_strip_value
64
- -------------------------------
65
-  (0.0ms) rollback transaction
66
-  (0.0ms) begin transaction
67
- ------------------------------------
68
- AuthoritiesTest: test_parse_language
69
- ------------------------------------
70
-  (0.1ms) rollback transaction
71
-  (0.0ms) begin transaction
72
- -----------------------------------------
73
- AuthoritiesTest: test_parse_name_for_role
74
- -----------------------------------------
75
-  (0.1ms) rollback transaction
76
-  (0.0ms) begin transaction
77
- --------------------------------
78
- AuthoritiesTest: test_parse_role
79
- --------------------------------
80
-  (0.1ms) rollback transaction
81
-  (0.0ms) begin transaction
82
- --------------------------------
83
- LCSHTest: test_lcsh_standardizer
84
- --------------------------------
85
-  (0.0ms) rollback transaction
86
-  (0.0ms) begin transaction
87
- ---------------------------------
88
- DatesTest: test_date_standardizer
89
- ---------------------------------
90
-  (0.0ms) rollback transaction
91
-  (0.1ms) begin transaction
92
- -------------------------------
93
- BplEnrichTest: test_strip_value
94
- -------------------------------
95
-  (0.1ms) rollback transaction
96
-  (0.0ms) begin transaction
97
- ---------------------------------
98
- DatesTest: test_date_standardizer
99
- ---------------------------------
100
-  (0.0ms) rollback transaction
101
-  (0.0ms) begin transaction
102
- --------------------------------
103
- LCSHTest: test_lcsh_standardizer
104
- --------------------------------
105
-  (0.0ms) rollback transaction
106
-  (0.0ms) begin transaction
107
- ------------------------------------
108
- AuthoritiesTest: test_parse_language
109
- ------------------------------------
110
-  (0.1ms) rollback transaction
111
-  (0.0ms) begin transaction
112
- -----------------------------------------
113
- AuthoritiesTest: test_parse_name_for_role
114
- -----------------------------------------
115
-  (0.1ms) rollback transaction
116
-  (0.0ms) begin transaction
117
- --------------------------------
118
- AuthoritiesTest: test_parse_role
119
- --------------------------------
120
-  (0.1ms) rollback transaction
121
-  (0.1ms) begin transaction
122
- ---------------------------------
123
- DatesTest: test_date_standardizer
124
- ---------------------------------
125
-  (0.0ms) rollback transaction
126
-  (0.0ms) begin transaction
127
- -------------------------------
128
- BplEnrichTest: test_strip_value
129
- -------------------------------
130
-  (0.0ms) rollback transaction
131
-  (0.0ms) begin transaction
132
- --------------------------------
133
- LCSHTest: test_lcsh_standardizer
134
- --------------------------------
135
-  (0.0ms) rollback transaction
136
1
   (0.1ms) begin transaction
137
2
  ------------------------------------
138
3
  AuthoritiesTest: test_parse_language
@@ -148,67 +13,7 @@ AuthoritiesTest: test_parse_name_for_role
148
13
  AuthoritiesTest: test_parse_role
149
14
  --------------------------------
150
15
   (0.1ms) rollback transaction
151
-  (0.1ms) begin transaction
152
- --------------------------------
153
- LCSHTest: test_lcsh_standardizer
154
- --------------------------------
155
-  (0.0ms) rollback transaction
156
-  (0.0ms) begin transaction
157
- ------------------------------------
158
- AuthoritiesTest: test_parse_language
159
- ------------------------------------
160
-  (0.1ms) rollback transaction
161
-  (0.0ms) begin transaction
162
- -----------------------------------------
163
- AuthoritiesTest: test_parse_name_for_role
164
- -----------------------------------------
165
-  (0.1ms) rollback transaction
166
-  (0.0ms) begin transaction
167
- --------------------------------
168
- AuthoritiesTest: test_parse_role
169
- --------------------------------
170
-  (0.1ms) rollback transaction
171
-  (0.0ms) begin transaction
172
- -------------------------------
173
- BplEnrichTest: test_strip_value
174
- -------------------------------
175
-  (0.0ms) rollback transaction
176
-  (0.0ms) begin transaction
177
- ---------------------------------
178
- DatesTest: test_date_standardizer
179
- ---------------------------------
180
-  (0.0ms) rollback transaction
181
-  (0.0ms) begin transaction
182
- --------------------------------
183
- LCSHTest: test_lcsh_standardizer
184
- --------------------------------
185
-  (0.0ms) rollback transaction
186
-  (0.0ms) begin transaction
187
- ------------------------------------
188
- AuthoritiesTest: test_parse_language
189
- ------------------------------------
190
-  (0.1ms) rollback transaction
191
-  (0.1ms) begin transaction
192
- -----------------------------------------
193
- AuthoritiesTest: test_parse_name_for_role
194
- -----------------------------------------
195
-  (0.1ms) rollback transaction
196
-  (0.0ms) begin transaction
197
- --------------------------------
198
- AuthoritiesTest: test_parse_role
199
- --------------------------------
200
-  (0.1ms) rollback transaction
201
-  (0.0ms) begin transaction
202
- -------------------------------
203
- BplEnrichTest: test_strip_value
204
- -------------------------------
205
-  (0.0ms) rollback transaction
206
16
   (0.0ms) begin transaction
207
- ---------------------------------
208
- DatesTest: test_date_standardizer
209
- ---------------------------------
210
-  (0.0ms) rollback transaction
211
-  (0.1ms) begin transaction
212
17
  --------------------------------
213
18
  LCSHTest: test_lcsh_standardizer
214
19
  --------------------------------
@@ -217,84 +22,9 @@ LCSHTest: test_lcsh_standardizer
217
22
  ---------------------------------
218
23
  DatesTest: test_date_standardizer
219
24
  ---------------------------------
220
-  (0.0ms) rollback transaction
221
-  (0.0ms) begin transaction
222
- -------------------------------
223
- BplEnrichTest: test_strip_value
224
- -------------------------------
225
-  (0.0ms) rollback transaction
226
-  (0.0ms) begin transaction
227
- ------------------------------------
228
- AuthoritiesTest: test_parse_language
229
- ------------------------------------
230
-  (0.1ms) rollback transaction
231
-  (0.0ms) begin transaction
232
- -----------------------------------------
233
- AuthoritiesTest: test_parse_name_for_role
234
- -----------------------------------------
235
-  (0.1ms) rollback transaction
236
-  (0.0ms) begin transaction
237
- --------------------------------
238
- AuthoritiesTest: test_parse_role
239
- --------------------------------
240
-  (0.1ms) rollback transaction
241
-  (0.1ms) begin transaction
242
- ------------------------------------
243
- AuthoritiesTest: test_parse_language
244
- ------------------------------------
245
-  (0.1ms) rollback transaction
246
-  (0.0ms) begin transaction
247
- -----------------------------------------
248
- AuthoritiesTest: test_parse_name_for_role
249
- -----------------------------------------
250
-  (0.1ms) rollback transaction
251
-  (0.0ms) begin transaction
252
- --------------------------------
253
- AuthoritiesTest: test_parse_role
254
- --------------------------------
255
25
   (0.1ms) rollback transaction
256
26
   (0.0ms) begin transaction
257
27
  -------------------------------
258
28
  BplEnrichTest: test_strip_value
259
29
  -------------------------------
260
30
   (0.0ms) rollback transaction
261
-  (0.0ms) begin transaction
262
- --------------------------------
263
- LCSHTest: test_lcsh_standardizer
264
- --------------------------------
265
-  (0.0ms) rollback transaction
266
-  (0.0ms) begin transaction
267
- ---------------------------------
268
- DatesTest: test_date_standardizer
269
- ---------------------------------
270
-  (0.1ms) rollback transaction
271
-  (0.1ms) begin transaction
272
- ------------------------------------
273
- AuthoritiesTest: test_parse_language
274
- ------------------------------------
275
-  (0.1ms) rollback transaction
276
-  (0.0ms) begin transaction
277
- -----------------------------------------
278
- AuthoritiesTest: test_parse_name_for_role
279
- -----------------------------------------
280
-  (0.1ms) rollback transaction
281
-  (0.0ms) begin transaction
282
- --------------------------------
283
- AuthoritiesTest: test_parse_role
284
- --------------------------------
285
-  (0.1ms) rollback transaction
286
-  (0.1ms) begin transaction
287
- -------------------------------
288
- BplEnrichTest: test_strip_value
289
- -------------------------------
290
-  (0.0ms) rollback transaction
291
-  (0.0ms) begin transaction
292
- --------------------------------
293
- LCSHTest: test_lcsh_standardizer
294
- --------------------------------
295
-  (0.1ms) rollback transaction
296
-  (0.0ms) begin transaction
297
- ---------------------------------
298
- DatesTest: test_date_standardizer
299
- ---------------------------------
300
-  (0.0ms) rollback transaction
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bpl_enrich
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boston Public Library
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-25 00:00:00.000000000 Z
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -168,47 +168,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.5.2
171
+ rubygems_version: 2.6.10
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Methods for enriching and standardizing metadata.
175
175
  test_files:
176
- - test/dates_test.rb
177
- - test/dummy/config.ru
178
- - test/dummy/app/helpers/application_helper.rb
179
- - test/dummy/app/assets/stylesheets/application.css
180
- - test/dummy/app/assets/javascripts/application.js
181
- - test/dummy/app/controllers/application_controller.rb
182
- - test/dummy/app/views/layouts/application.html.erb
183
- - test/dummy/log/test.log
184
- - test/dummy/log/development.log
185
- - test/dummy/bin/rails
186
- - test/dummy/bin/bundle
187
- - test/dummy/bin/rake
188
- - test/dummy/public/422.html
189
- - test/dummy/public/favicon.ico
190
- - test/dummy/public/500.html
191
- - test/dummy/public/404.html
192
- - test/dummy/README.rdoc
193
- - test/dummy/Rakefile
194
- - test/dummy/db/test.sqlite3
195
- - test/dummy/config/routes.rb
196
- - test/dummy/config/application.rb
197
- - test/dummy/config/environment.rb
198
- - test/dummy/config/initializers/wrap_parameters.rb
176
+ - test/lcsh_test.rb
177
+ - test/bpl_enrich_test.rb
178
+ - test/test_helper.rb
179
+ - test/authorities_test.rb
180
+ - test/dummy/config/initializers/secret_token.rb
199
181
  - test/dummy/config/initializers/backtrace_silencers.rb
200
- - test/dummy/config/initializers/mime_types.rb
201
182
  - test/dummy/config/initializers/filter_parameter_logging.rb
202
183
  - test/dummy/config/initializers/session_store.rb
184
+ - test/dummy/config/initializers/wrap_parameters.rb
185
+ - test/dummy/config/initializers/mime_types.rb
203
186
  - test/dummy/config/initializers/inflections.rb
204
- - test/dummy/config/initializers/secret_token.rb
205
- - test/dummy/config/boot.rb
206
- - test/dummy/config/locales/en.yml
207
187
  - test/dummy/config/environments/test.rb
208
- - test/dummy/config/environments/development.rb
209
188
  - test/dummy/config/environments/production.rb
189
+ - test/dummy/config/environments/development.rb
190
+ - test/dummy/config/locales/en.yml
191
+ - test/dummy/config/routes.rb
192
+ - test/dummy/config/environment.rb
210
193
  - test/dummy/config/database.yml
211
- - test/lcsh_test.rb
212
- - test/authorities_test.rb
213
- - test/bpl_enrich_test.rb
214
- - test/test_helper.rb
194
+ - test/dummy/config/application.rb
195
+ - test/dummy/config/boot.rb
196
+ - test/dummy/bin/rake
197
+ - test/dummy/bin/rails
198
+ - test/dummy/bin/bundle
199
+ - test/dummy/Rakefile
200
+ - test/dummy/log/test.log
201
+ - test/dummy/log/development.log
202
+ - test/dummy/db/test.sqlite3
203
+ - test/dummy/config.ru
204
+ - test/dummy/README.rdoc
205
+ - test/dummy/app/assets/stylesheets/application.css
206
+ - test/dummy/app/assets/javascripts/application.js
207
+ - test/dummy/app/controllers/application_controller.rb
208
+ - test/dummy/app/helpers/application_helper.rb
209
+ - test/dummy/app/views/layouts/application.html.erb
210
+ - test/dummy/public/500.html
211
+ - test/dummy/public/422.html
212
+ - test/dummy/public/404.html
213
+ - test/dummy/public/favicon.ico
214
+ - test/dates_test.rb