bug 9370: improve splitting of LC call numbers for labels
Use the Perl module Library::CallNumber::LC to parse and split LC call numbers when generating spine labels. For example, QH541.15.C6 C25 2012 should be split as follows: QH 541.15 .C6 C25 2012 To test, create an item with call number QH541.15.C6 C25 2012 and classification source LC, then create a spine label for that item using a layout of type 'biblio' that has the split call numbers option enabled. The call number should be split as indicated above. Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Galen Charlton <gmc@esilibrary.com> (cherry picked from commitedb8bddff0) Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> (cherry picked from commit10f5822daa) Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> (cherry picked from commit10f5822daa)
This commit is contained in:
parent
0e82fef70b
commit
56ea58ecda
|
|
@ -7,6 +7,7 @@ use Text::Wrap;
|
|||
use Algorithm::CheckDigits;
|
||||
use Text::CSV_XS;
|
||||
use Data::Dumper;
|
||||
use Library::CallNumber::LC;
|
||||
|
||||
use C4::Context;
|
||||
use C4::Debug;
|
||||
|
|
@ -113,18 +114,10 @@ sub _split_lccn {
|
|||
my ($lccn) = @_;
|
||||
$_ = $lccn;
|
||||
# lccn examples: 'HE8700.7 .P6T44 1983', 'BS2545.E8 H39 1996';
|
||||
my (@parts) = m/
|
||||
^([a-zA-Z]+) # HE # BS
|
||||
(\d+(?:\.\d)*) # 8700.7 # 2545
|
||||
\s*
|
||||
(\.*\D+\d*) # .P6 # .E8
|
||||
\s*
|
||||
(.*) # T44 1983 # H39 1996 # everything else (except any bracketing spaces)
|
||||
\s*
|
||||
/x;
|
||||
unless (scalar @parts) {
|
||||
my @parts = Library::CallNumber::LC->new($lccn)->components();
|
||||
unless (scalar @parts && defined $parts[0]) {
|
||||
warn sprintf('regexp failed to match string: %s', $_);
|
||||
push @parts, $_; # if no match, just push the whole string.
|
||||
@parts = $_; # if no match, just use the whole string.
|
||||
}
|
||||
push @parts, split /\s+/, pop @parts; # split the last piece into an arbitrary number of pieces at spaces
|
||||
$debug and warn "split_lccn array: ", join(" | ", @parts), "\n";
|
||||
|
|
|
|||
Loading…
Reference in New Issue