bpl_enrich 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69ccce9a084733f7f9fb63c6a26dba0c74818829
4
- data.tar.gz: e33886a42dcf60f031932f22181cfd82fcb0fa78
3
+ metadata.gz: f724458c14578154f1ec766c46a67d25b2df49c2
4
+ data.tar.gz: 3b922f75a5646e7e856aa6746c493a7b8982f67b
5
5
  SHA512:
6
- metadata.gz: be415afcc29ca30c9fa7dab438b5a7949dccc22586ae82ad14783c637063e59a14f4da59470454facfcfc3d000cf9c5117ae8e001da9c139a5d598a64e538e5e
7
- data.tar.gz: ae47de03455d706e6578967f9bb79564911c550e8fc7aa3b77079f28d0b99d62397e94b86d9beb63e11320328760cc7fb05c90803f17755382d29df8f23ac641
6
+ metadata.gz: 124289eebef362c4332d5e7fdd57baff97c87f125a81a9374ef1f26826debabd15afe62b234c91487b5e944ea1a128e2b47112c14bff6aaff7c5fdee9ffcebfa
7
+ data.tar.gz: 906c244fe8a40ed92add65908ad2fe390723858738fe1ef83e23bafb953677c427d1be1db99c974c3cdb4e95ebc3542e2723e867a58d549cb085faaccecb44d0
@@ -52,7 +52,7 @@ module BplEnrich
52
52
  # weed out obvious bad dates before processing
53
53
  if (value.match(/([Pp]re|[Pp]ost|[Bb]efore|[Aa]fter|[Uu]nknown|[Uu]ndated|n\.d\.)/)) ||
54
54
  (value.match(/\d\d\d\d-\z/)) || # 1975-
55
- (value.match(/\d\d-\d\d\/\d\d/)) || # 1975-09-09/10
55
+ (value.match(/\d\d-\d\d\/\d\d/) && !value.match(/\d\d-\d\d\/\d\d\d\d/)) || # 1975-09-09/10 but not 1975-09/1975-10
56
56
  (value.match(/\d*\(\d*\)/)) || # 1975(1976)
57
57
  (value.scan(/\d\d\d\d/).length > 2) || # 1861/1869/1915
58
58
  (value.scan(/([Ee]arly|[Ll]ate|[Mm]id|[Ww]inter|[Ss]pring|[Ss]ummer|[Ff]all)/).length > 1) ||
@@ -91,7 +91,10 @@ module BplEnrich
91
91
  # convert weird span indicators ('or','and','||'), remove extraneous text
92
92
  value = value.gsub(/(or|and|\|\|)/,'-').gsub(/[A-Za-z\?\s]/,'')
93
93
 
94
- if value.match(/\A[12][\d]{3}-[01][\d]-[12][\d]{3}-[01][\d]\z/) # 1895-05-1898-01
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
+ date_data_range_start = value[0..9]
96
+ date_data_range_end = value[-10..-1]
97
+ elsif value.match(/\A[12][\d]{3}-[01][\d][\/-][12][\d]{3}-[01][\d]\z/) # 1895-05-1898-01 or 1895-05/1898-01
95
98
  date_data_range_start = value[0..6]
96
99
  date_data_range_end = value[-7..-1]
97
100
  elsif value.match(/\A[12][\d]{3}\/[12][\d]{3}\z/) # 1987/1988
@@ -1,3 +1,3 @@
1
1
  module BplEnrich
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/test/dates_test.rb CHANGED
@@ -6,80 +6,92 @@ class DatesTest < ActiveSupport::TestCase
6
6
  #Month dates
7
7
  result = BplEnrich::Dates.standardize('April 1983')
8
8
  assert_equal '1983-04', result[:single_date]
9
- assert_equal nil, result[:date_range]
10
- assert_equal nil, result[:date_note]
9
+ assert_nil result[:date_range]
10
+ assert_nil result[:date_note]
11
11
 
12
12
  result = BplEnrich::Dates.standardize('April 7, 1983')
13
13
  assert_equal '1983-04-07', result[:single_date]
14
- assert_equal nil, result[:date_range]
15
- assert_equal nil, result[:date_note]
14
+ assert_nil result[:date_range]
15
+ assert_nil result[:date_note]
16
16
 
17
17
  result = BplEnrich::Dates.standardize('April 7.1983 (Easter)')
18
18
  assert_equal '1983-04-07', result[:single_date]
19
- assert_equal nil, result[:date_range]
19
+ assert_nil result[:date_range]
20
20
  assert_equal 'April 7.1983 (Easter)', result[:date_note]
21
21
 
22
22
  result = BplEnrich::Dates.standardize('1983.April.7 (Easter)')
23
23
  assert_equal '1983-04-07', result[:single_date]
24
- assert_equal nil, result[:date_range]
24
+ assert_nil result[:date_range]
25
25
  assert_equal '1983.April.7 (Easter)', result[:date_note]
26
26
 
27
27
  result = BplEnrich::Dates.standardize('between April 2014 and May 2014')
28
- assert_equal nil, result[:single_date]
28
+ assert_nil result[:single_date]
29
29
  assert_equal '2014-04', result[:date_range][:start]
30
30
  assert_equal '2014-05', result[:date_range][:end]
31
- assert_equal nil, result[:date_note]
31
+ assert_nil result[:date_note]
32
32
 
33
33
  result = BplEnrich::Dates.standardize('2000-06')
34
34
  assert_equal '2000-06', result[:single_date]
35
- assert_equal nil, result[:date_range]
36
- assert_equal nil, result[:date_note]
35
+ assert_nil result[:date_range]
36
+ assert_nil result[:date_note]
37
37
 
38
38
  result = BplEnrich::Dates.standardize('17 June 1962')
39
39
  assert_equal '1962-06-17', result[:single_date]
40
- assert_equal nil, result[:date_range]
41
- assert_equal nil, result[:date_note]
40
+ assert_nil result[:date_range]
41
+ assert_nil result[:date_note]
42
42
 
43
43
  result = BplEnrich::Dates.standardize('1860/10-1862/04')
44
- assert_equal nil, result[:single_date]
44
+ assert_nil result[:single_date]
45
45
  assert_equal '1860-10', result[:date_range][:start]
46
46
  assert_equal '1862-04', result[:date_range][:end]
47
- assert_equal nil, result[:date_note]
47
+ assert_nil result[:date_note]
48
48
 
49
49
 
50
50
  result = BplEnrich::Dates.standardize('[11-12-1928?]')
51
51
  assert_equal '1928-11-12', result[:single_date]
52
- assert_equal nil, result[:date_range]
53
- assert_equal nil, result[:date_note]
52
+ assert_nil result[:date_range]
53
+ assert_nil result[:date_note]
54
54
  assert_equal 'questionable', result[:date_qualifier]
55
55
 
56
56
  result = BplEnrich::Dates.standardize('Circa 2000')
57
57
  assert_equal '2000', result[:single_date]
58
- assert_equal nil, result[:date_range]
59
- assert_equal nil, result[:date_note]
58
+ assert_nil result[:date_range]
59
+ assert_nil result[:date_note]
60
60
  assert_equal 'approximate', result[:date_qualifier]
61
- assert_equal nil, result[:date_note]
62
61
 
63
62
  result = BplEnrich::Dates.standardize('1995-01-00')
64
63
  assert_equal '1995-01', result[:single_date]
65
- assert_equal nil, result[:date_range]
66
- assert_equal nil, result[:date_note]
67
- assert_equal nil, result[:date_qualifier]
68
- assert_equal nil, result[:date_note]
64
+ assert_nil result[:date_range]
65
+ assert_nil result[:date_note]
66
+ assert_nil result[:date_qualifier]
69
67
 
70
68
  result = BplEnrich::Dates.standardize('1996-00-00')
71
69
  assert_equal '1996', result[:single_date]
72
- assert_equal nil, result[:date_range]
73
- assert_equal nil, result[:date_note]
74
- assert_equal nil, result[:date_qualifier]
75
- assert_equal nil, result[:date_note]
70
+ assert_nil result[:date_range]
71
+ assert_nil result[:date_note]
72
+ assert_nil result[:date_qualifier]
76
73
 
77
74
  result = BplEnrich::Dates.standardize('1997-00')
78
75
  assert_equal '1997', result[:single_date]
79
- assert_equal nil, result[:date_range]
80
- assert_equal nil, result[:date_note]
81
- assert_equal nil, result[:date_qualifier]
82
- assert_equal nil, result[:date_note]
76
+ assert_nil result[:date_range]
77
+ assert_nil result[:date_note]
78
+ assert_nil result[:date_qualifier]
79
+
80
+ # Example 1 from Woods Hole Scientific Community
81
+ result = BplEnrich::Dates.standardize('1939-04-22/1941-11-30')
82
+ assert_nil result[:single_date]
83
+ assert_equal '1939-04-22', result[:date_range][:start]
84
+ assert_equal '1941-11-30', result[:date_range][:end]
85
+ assert_nil result[:date_qualifier]
86
+ assert_nil result[:date_note]
87
+
88
+ # Example 2 from Woods Hole Scientific Community... FIXME: Potentially just 1933?
89
+ result = BplEnrich::Dates.standardize('1933-01-01/1933-12-31')
90
+ assert_nil result[:single_date]
91
+ assert_equal '1933-01-01', result[:date_range][:start]
92
+ assert_equal '1933-12-31', result[:date_range][:end]
93
+ assert_nil result[:date_qualifier]
94
+ assert_nil result[:date_note]
83
95
  end
84
96
 
85
97
 
@@ -238,3 +238,63 @@ AuthoritiesTest: test_parse_name_for_role
238
238
  AuthoritiesTest: test_parse_role
239
239
  --------------------------------
240
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
+  (0.1ms) rollback transaction
256
+  (0.0ms) begin transaction
257
+ -------------------------------
258
+ BplEnrichTest: test_strip_value
259
+ -------------------------------
260
+  (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.6
4
+ version: 0.0.7
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-12 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails