anystyle-parser 0.6.1 → 0.6.2
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 +4 -4
- data/lib/anystyle/parser/normalizer.rb +5 -4
- data/lib/anystyle/parser/version.rb +1 -1
- data/spec/anystyle/parser/normalizer_spec.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3157c9bbc6098612aac186fea98a8e43943f2262
|
4
|
+
data.tar.gz: 961f00097e44875c0e3e3aada77944f90ba2dfbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 801fa8446b680f8e21e8435d6d30b8af7e1d2a48976b27a034455a2f95913d9c71abe2ccc64927bbca0c20d7e67aa8c6ebc3c01c03adc6a6ec281ea8c5df93c6
|
7
|
+
data.tar.gz: 7f87f5cfb0094fc943a37c78a493f41a0c9444d60d59280516b5e7ef2d5f61386b7640a11a906211fb5ac0fcea25ae545f62172add438f8fd8074f1470838692
|
@@ -94,8 +94,8 @@ module Anystyle
|
|
94
94
|
|
95
95
|
editors.gsub!(/^\W+|\W+$/, '')
|
96
96
|
editors.gsub!(/^in:?\s+/i, '')
|
97
|
-
editors.gsub!(/[^[:alpha:]]*[Ee]d(s|itors?|ited)
|
98
|
-
editors.gsub!(/[^[:alpha:]]*([Hh]rsg|Herausgeber)[^[:alpha:]]*/, '')
|
97
|
+
editors.gsub!(/[^[:alpha:]]*[Ee]d(s|itors?|ited)?\b[^[:alpha:]]*/, '')
|
98
|
+
editors.gsub!(/[^[:alpha:]]*([Hh]rsg|Herausgeber)\b[^[:alpha:]]*/, '')
|
99
99
|
editors.gsub!(/\bby\b/i, '')
|
100
100
|
|
101
101
|
is_trans = !!editors.gsub!(/[^[:alpha:]]*trans(lated)?[^[:alpha:]]*/i, '')
|
@@ -110,7 +110,7 @@ module Anystyle
|
|
110
110
|
translators = hash[:translator]
|
111
111
|
|
112
112
|
translators.gsub!(/^\W+|\W+$/, '')
|
113
|
-
translators.gsub!(/[^[:alpha:]]*trans(lated)
|
113
|
+
translators.gsub!(/[^[:alpha:]]*trans(lated)?\b[^[:alpha:]]*/i, '')
|
114
114
|
translators.gsub!(/\bby\b/i, '')
|
115
115
|
|
116
116
|
hash[:translator] = normalize_names(translators)
|
@@ -121,7 +121,8 @@ module Anystyle
|
|
121
121
|
directors = hash[:director]
|
122
122
|
|
123
123
|
directors.gsub!(/^\W+|\W+$/, '')
|
124
|
-
directors.gsub!(/[^[:alpha:]]*direct(or|ed)
|
124
|
+
directors.gsub!(/[^[:alpha:]]*direct(or|ed)?\b:w
|
125
|
+
[^[:alpha:]]*/i, '')
|
125
126
|
directors.gsub!(/\bby\b/i, '')
|
126
127
|
|
127
128
|
hash[:director] = normalize_names(directors)
|
@@ -52,6 +52,22 @@ module Anystyle
|
|
52
52
|
|
53
53
|
end
|
54
54
|
|
55
|
+
describe '#normalize_editor' do
|
56
|
+
it "strips in from beginning" do
|
57
|
+
n.normalize_editor(:editor => 'In D. Knuth (ed.)').should == { :editor => 'Knuth, D.' }
|
58
|
+
n.normalize_editor(:editor => 'In: D. Knuth (ed.)').should == { :editor => 'Knuth, D.' }
|
59
|
+
n.normalize_editor(:editor => 'in: D. Knuth ed.').should == { :editor => 'Knuth, D.' }
|
60
|
+
n.normalize_editor(:editor => 'in D. Knuth (ed)').should == { :editor => 'Knuth, D.' }
|
61
|
+
end
|
62
|
+
|
63
|
+
it "does not strip ed from name" do
|
64
|
+
n.normalize_editor(:editor => 'In Edward Wood').should == { :editor => 'Wood, Edward' }
|
65
|
+
n.normalize_editor(:editor => 'ed by Edward Wood').should == { :editor => 'Wood, Edward' }
|
66
|
+
n.normalize_editor(:editor => 'ed. by Edward Wood').should == { :editor => 'Wood, Edward' }
|
67
|
+
n.normalize_editor(:editor => 'ed by Edward Wood').should == { :editor => 'Wood, Edward' }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
55
71
|
describe 'editors extraction' do
|
56
72
|
it 'recognizes editors in the author field' do
|
57
73
|
n.normalize_author(:author => 'D. Knuth (ed.)').should == { :editor => 'Knuth, D.' }
|