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 +4 -4
- data/lib/bpl_enrich/dates.rb +5 -2
- data/lib/bpl_enrich/version.rb +1 -1
- data/test/dates_test.rb +43 -31
- data/test/dummy/log/test.log +60 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f724458c14578154f1ec766c46a67d25b2df49c2
|
4
|
+
data.tar.gz: 3b922f75a5646e7e856aa6746c493a7b8982f67b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 124289eebef362c4332d5e7fdd57baff97c87f125a81a9374ef1f26826debabd15afe62b234c91487b5e944ea1a128e2b47112c14bff6aaff7c5fdee9ffcebfa
|
7
|
+
data.tar.gz: 906c244fe8a40ed92add65908ad2fe390723858738fe1ef83e23bafb953677c427d1be1db99c974c3cdb4e95ebc3542e2723e867a58d549cb085faaccecb44d0
|
data/lib/bpl_enrich/dates.rb
CHANGED
@@ -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/) #
|
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
|
data/lib/bpl_enrich/version.rb
CHANGED
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
|
-
|
10
|
-
|
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
|
-
|
15
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
36
|
-
|
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
|
-
|
41
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
53
|
-
|
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
|
-
|
59
|
-
|
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
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
|
data/test/dummy/log/test.log
CHANGED
@@ -238,3 +238,63 @@ AuthoritiesTest: test_parse_name_for_role
|
|
238
238
|
AuthoritiesTest: test_parse_role
|
239
239
|
--------------------------------
|
240
240
|
[1m[35m (0.1ms)[0m rollback transaction
|
241
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
242
|
+
------------------------------------
|
243
|
+
AuthoritiesTest: test_parse_language
|
244
|
+
------------------------------------
|
245
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
246
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
247
|
+
-----------------------------------------
|
248
|
+
AuthoritiesTest: test_parse_name_for_role
|
249
|
+
-----------------------------------------
|
250
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
251
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
252
|
+
--------------------------------
|
253
|
+
AuthoritiesTest: test_parse_role
|
254
|
+
--------------------------------
|
255
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
256
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
257
|
+
-------------------------------
|
258
|
+
BplEnrichTest: test_strip_value
|
259
|
+
-------------------------------
|
260
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
261
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
262
|
+
--------------------------------
|
263
|
+
LCSHTest: test_lcsh_standardizer
|
264
|
+
--------------------------------
|
265
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
266
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
267
|
+
---------------------------------
|
268
|
+
DatesTest: test_date_standardizer
|
269
|
+
---------------------------------
|
270
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
271
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
272
|
+
------------------------------------
|
273
|
+
AuthoritiesTest: test_parse_language
|
274
|
+
------------------------------------
|
275
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
276
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
277
|
+
-----------------------------------------
|
278
|
+
AuthoritiesTest: test_parse_name_for_role
|
279
|
+
-----------------------------------------
|
280
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
281
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
282
|
+
--------------------------------
|
283
|
+
AuthoritiesTest: test_parse_role
|
284
|
+
--------------------------------
|
285
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
286
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
287
|
+
-------------------------------
|
288
|
+
BplEnrichTest: test_strip_value
|
289
|
+
-------------------------------
|
290
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
291
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
292
|
+
--------------------------------
|
293
|
+
LCSHTest: test_lcsh_standardizer
|
294
|
+
--------------------------------
|
295
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
296
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
297
|
+
---------------------------------
|
298
|
+
DatesTest: test_date_standardizer
|
299
|
+
---------------------------------
|
300
|
+
[1m[35m (0.0ms)[0m 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.
|
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-
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|