Class: NacoNormalizer
- Inherits:
-
Object
- Object
- NacoNormalizer
- Defined in:
- lib/naconormalizer.rb,
lib/naconormalizer/version.rb
Overview
A tiny shim around the OCLC's java code that performs NACO normalization, used by libraries (and others) to normalize author and title strings for sorting purposes.
See http://www.loc.gov/aba/pcc/naco/normrule-2.html
Java code adapted from https://code.google.com/p/oclcnaconormalizer/ and copyright OCLC
Constant Summary collapse
- OCLCNormalizer =
org.oclc.util::NacoNormalize
- Defaults =
{ :keep_first_comma => true }
- VERSION =
"1.0.1"
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ NacoNormalizer
constructor
Create a new normalizer that will use the passed options (if any).
-
#normalize(str, keep_first_comma = @keep_first_comma) ⇒ String
Normalize a string using the options passed to the constructor.
Constructor Details
#initialize(opts = {}) ⇒ NacoNormalizer
Create a new normalizer that will use the passed options (if any)
33 34 35 36 |
# File 'lib/naconormalizer.rb', line 33 def initialize(opts={}) opts = opts.merge(Defaults) @keep_first_comma = opts[:keep_first_comma] end |
Instance Method Details
#normalize(str, keep_first_comma = @keep_first_comma) ⇒ String
Normalize a string using the options passed to the constructor
41 42 43 |
# File 'lib/naconormalizer.rb', line 41 def normalize(str, keep_first_comma = @keep_first_comma ) OCLCNormalizer.nacoNormalize2007(str, keep_first_comma) end |