Lingua-EN-NameCase-1.21/000755 000765 000024 00000000000 13754220611 014551 5ustar00njhstaff000000 000000 Lingua-EN-NameCase-1.21/Changes000644 000765 000024 00000006534 13754220477 016066 0ustar00njhstaff000000 000000 Revision history for Lingua-EN-NameCase ======================================= 1.21 Sun Nov 15 07:38:11 EST 2020 Fix CPAN breakage 1.20 Fri Nov 13 15:20:30 EST 2020 No changes to the code, new maintainer - thanks to BARBIE 1.19 2015-01-29 - added use warnings for CPANTS completeness. 1.18 2014-10-11 - fixed license fields in META.json to be lists. - simplified parameter logic checks. - added tests to check bad calls. - Devel::Cover = 100% 1.17 2014-08-02 - switch to Test::More in tests. - RT#88359 - typo fix (thanks to dsteinbrunner). - RT#50047 - roman numerals optional (thanks to degatcpan). - added Post-Nominial Initials, based on RT#47708 (thanks to Dave Gray and Mark Summerfield for the ideas). The current list isn't exhaustive, but should suffice for now. - RT#46669 - Ben first name (thanks to Dave Gray). - added $HEBREW switch. - added 'bat', daughter of, in HEBREW. 1.16 2014-07-24 - new maintainer: Barbie. - created Changes, taken from POD. - moved module into lib directory path. - updated copyright and license. - added LICENSE file. - reworked Makefile.PL for clarity. - minimum perl version is now 5.006. - added META.json and updated META.yml. - extended test suite. 1.15 2008-02-27 - Fixed the version number. 1.14 2007-04-27 - Added 16 "Mac" exceptions provided by Stuart McConnachie. The license is now "the same terms as Perl itself". 1.13 2002-04-26 - Changed $SPANISH_EL to $SPANISH and now 'La' => 'la' unless $SPANISH is set in which case 'La' => 'La'. Again thanks to Aaron Patterson. 1.12 2002-04-25 - Al, Ben and Van are preserved if single names and namecased otherwise, e.g. 'Al' => 'Al', 'Al Fahd' => 'al Fahd'. Added $SPANISH_EL variable. All thanks to a suggestion by Aaron Patterson. 1.11 2000-11-24 - Added use locale at the suggestion of Eric Kolve. It should have been there in the first place. 1.10 1999-11-15 - Added code for names with roman numerals, thanks to David Lynn Rice for this suggestion. (If you need to go beyond LXXXIX let me know.) 1.08 1999-09-10 - Renamed Text-NameCase => Lingua-EN-NameCase - Renamed package Lingua::EN::NameCase.pm as per John Porter's (CPAN) suggestion. 1.08 1999-09-10 - Minor change to packaging for CPAN. 1.07 1999-08-11 - Changed licence to LGPL. 1.06 1999-08-06 - Renamed NameCase => Text-NameCase 1.06 1999-07-30 - Modified for CPAN and automatic testing. Stopped using $_ as the default argument. 1.04 1999-05-10 - nc can now use $_ as its default argument e.g. "$ans = nc ;" and "nc ;", both of which set $_, with the first one setting $ans also. 1,03 1999-05-05 - Copied Kim Ryan's Mc/Mac solution from his NameParse.pm and replaced my Mc/Mac solution with his. 1.00 1999-03-01 - Added Mac with Mack as an exception, thanks to Kim Ryan for this. 0.03 1999-01-18 - Second public release. 0.02 1998-06-25 - First public release. 0.01 1998-04-20 - First release. Lingua-EN-NameCase-1.21/lib/000755 000765 000024 00000000000 13754220611 015317 5ustar00njhstaff000000 000000 Lingua-EN-NameCase-1.21/LICENSE000644 000765 000024 00000000405 13753543344 015567 0ustar00njhstaff000000 000000 LICENSE for Lingua-EN-NameCase Copyright © 1998-2014 Mark Summerfield. All Rights Reserved. Copyright © 2014-2015 Barbie for Miss Barbell Productions. This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2. Lingua-EN-NameCase-1.21/Makefile.PL000644 000765 000024 00000003141 13753604024 016525 0ustar00njhstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use 5.006; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Lingua::EN::NameCase', # AUTHOR => 'Barbie ', AUTHOR => q{Nigel Horne }, VERSION_FROM => 'lib/Lingua/EN/NameCase.pm', ABSTRACT => "Correctly case a person's name from UPERCASE or lowcase", LICENSE => 'artistic_2', PL_FILES => {}, NO_META => 1, PREREQ_PM => { 'Carp' => '0', 'Exporter' => '0', # build/test prereqs 'IO::File' => '0', 'Test::More' => '0.70' }, TEST_REQUIRES => { 'Test::Most' => 0, }, 'LIBS' => [''], # e.g., '-lm' 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING' 'INC' => '', # e.g., '-I/usr/include/other' dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, META_MERGE => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => 'git://github.com/nigelhorne/Lingua-EN-NameCase.git', web => 'https://github.com/nigelhorne/Lingua-EN-NameCase', repository => 'https://github.com/nigelhorne/Lingua-EN-NameCase', }, bugtracker => { # web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Lingua-EN-NameCase', # mailto => 'bug-Lingua-EN-NameCase@rt.cpan.org' web => 'https://github.com/nigelhorne/Lingua-EN-NameCase/issues', url => 'https://github.com/nigelhorne/Lingua-EN-NameCase/issues', } }, }, ); Lingua-EN-NameCase-1.21/MANIFEST000644 000765 000024 00000000432 13754105630 015704 0ustar00njhstaff000000 000000 Changes lib/Lingua/EN/NameCase.pm LICENSE Makefile.PL MANIFEST MANIFEST.SKIP README README.md t/00use.t t/10namecase.t t/11examples.t t/12badcalls.t t/90podtest.t t/91podcover.t t/94metatest.t t/95changedate.t t/96metatest.t t/eol.t t/links.t t/no404s.t t/pod-cm.t t/pod.t t/vars.t Lingua-EN-NameCase-1.21/MANIFEST.SKIP000644 000765 000024 00000002044 13754067530 016460 0ustar00njhstaff000000 000000 #!start included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.github\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. #!end included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP \.travis\.yml \.appveyor\.yml \.releaserc \.lwpcookies HTML-.* Lingua-EN-NameCase-1.21/README000644 000765 000024 00000011053 13753543344 015443 0ustar00njhstaff000000 000000 =head1 NAME NameCase - Perl module to fix the case of people's names. =head1 SYNOPSIS # Working with scalars; complementing lc and uc. use Lingua::EN::NameCase qw( nc ) ; $FixedCasedName = nc( $OriginalName ) ; $FixedCasedName = nc( \$OriginalName ) ; # Working with arrays or array references. use Lingua::EN::NameCase 'NameCase' ; $FixedCasedName = NameCase( $OriginalName ) ; @FixedCasedNames = NameCase( @OriginalNames ) ; $FixedCasedName = NameCase( \$OriginalName ) ; @FixedCasedNames = NameCase( \@OriginalNames ) ; NameCase( \@OriginalNames ) ; # In-place. # NameCase will not change a scalar in-place, i.e. NameCase( \$OriginalName ) ; # WRONG: null operation. $Lingua::EN::NameCase::SPANISH = 1; # Now 'El' => 'El' instead of (default) Greek 'El' => 'el'. # Now 'La' => 'La' instead of (default) French 'La' => 'la'. =head1 DESCRIPTION Forenames and surnames are often stored either wholly in UPPERCASE or wholly in lowercase. This module allows you to convert names into the correct case where possible. Although forenames and surnames are normally stored separately if they do appear in a single string, whitespace separated, NameCase and nc deal correctly with them. NameCase currently correctly name cases names which include any of the following: Mc, Mac, al, el, ap, da, de, delle, della, di, du, del, der, la, le, lo, van and von. It correctly deals with names which contain apostrophies and hyphens too. =head2 EXAMPLE FIXES Original Name Case -------- --------- KEITH Keith LEIGH-WILLIAMS Leigh-Williams MCCARTHY McCarthy O'CALLAGHAN O'Callaghan ST. JOHN St. John plus "son (daughter) of" etc. in various languages, e.g.: VON STREIT von Streit VAN DYKE van Dyke AP LLWYD DAFYDD ap Llwyd Dafydd etc. plus names with roman numerals (up to 89, LXXXIX), e.g.: henry viii Henry VIII louis xiv Louis XIV =head1 BUGS The module covers the rules that I know of. There are probably a lot more rules, exceptions etc. for "Western"-style languages which could be incorporated. There are probably lots of exceptions and problems - but as a general data 'cleaner' it may be all you need. Use Kim Ryan's NameParse.pm for any really sophisticated name parsing. =head1 CHANGES These are the original change comments. These have now been moved to the new Changes file within the distribution. 1998/04/20 First release. 1998/06/25 First public release. 1999/01/18 Second public release. 1999/02/08 Added Mac with Mack as an exception, thanks to Kim Ryan for this. 1999/05/05 Copied Kim Ryan's Mc/Mac solution from his NameParse.pm and replaced my Mc/Mac solution with his. 1999/05/08 nc can now use $_ as its default argument e.g. "$ans = nc ;" and "nc ;", both of which set $_, with the first one setting $ans also. 1999/07/30 Modified for CPAN and automatic testing. Stopped using $_ as the default argument. 1999/08/08 Changed licence to LGPL. 1999/09/07 Minor change to packaging for CPAN. 1999/09/09 Renamed package Lingua::EN::NameCase.pm as per John Porter's (CPAN) suggestion. 1999/11/13 Added code for names with roman numerals, thanks to David Lynn Rice for this suggestion. (If you need to go beyond LXXXIX let me know.) 2000/11/22 Added use locale at the suggestion of Eric Kolve. It should have been there in the first place. 2002/04/25 Al, Ben and Van are preserved if single names and namecased otherwise, e.g. 'Al' => 'Al', 'Al Fahd' => 'al Fahd'. Added $SPANISH_EL variable. All thanks to a suggestion by Aaron Patterson. 2002/04/26 Changed $SPANISH_EL to $SPANISH and now 'La' => 'la' unless $SPANISH is set in which case 'La' => 'La'. Again thanks to Aaron Patterson. 2007/04/27 Added 16 "Mac" exceptions provided by Stuart McConnachie. The license is now "the same terms as Perl itself". 2008/02/07 Fixed the version number. =head1 AUTHOR Mark Summerfield - 1998-2014 Barbie 2014-present =head1 ACKNOWLEDGEMENTS Thanks to Kim Ryan for his Mc/Mac solution. =head1 COPYRIGHT Copyright (c) Mark Summerfield 1998-2014. All Rights Reserved. Copyright (c) Barbie 2014-2015. All Rights Reserved. This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2. =cut Lingua-EN-NameCase-1.21/README.md000644 000765 000024 00000007143 13754104440 016036 0ustar00njhstaff000000 000000 # NAME Lingua::EN::NameCase - Correctly case a person's name from UPERCASE or lowcase # VERSION Version 0.70 # SYNOPSIS # Working with scalars; complementing lc and uc. use Lingua::EN::NameCase qw( nc ); $FixedCasedName = nc( $OriginalName ); $FixedCasedName = nc( \$OriginalName ); # Working with arrays or array references. use Lingua::EN::NameCase 'NameCase'; $FixedCasedName = NameCase( $OriginalName ); @FixedCasedNames = NameCase( @OriginalNames ); $FixedCasedName = NameCase( \$OriginalName ); @FixedCasedNames = NameCase( \@OriginalNames ); NameCase( \@OriginalNames ) ; # In-place. # NameCase will not change a scalar in-place, i.e. NameCase( \$OriginalName ) ; # WRONG: null operation. $Lingua::EN::NameCase::SPANISH = 1; # Now 'El' => 'El' instead of (default) Greek 'El' => 'el'. # Now 'La' => 'La' instead of (default) French 'La' => 'la'. $Lingua::EN::NameCase::HEBREW = 0; # Now 'Aharon BEN Amram Ha-Kohein' => 'Aharon Ben Amram Ha-Kohein' # instead of (default) => 'Aharon ben Amram Ha-Kohein'. $Lingua::EN::NameCase::ROMAN = 0; # Now 'Li' => 'Li' instead of (default) 'Li' => 'LI'. $Lingua::EN::NameCase::POSTNOMINAL = 0; # Now 'PHD' => 'PhD' instead of (default) 'PHD' => 'Phd'. # DESCRIPTION Forenames and surnames are often stored either wholly in UPPERCASE or wholly in lowercase. This module allows you to convert names into the correct case where possible. Although forenames and surnames are normally stored separately if they do appear in a single string, whitespace separated, NameCase and nc deal correctly with them. NameCase currently correctly name cases names which include any of the following: Mc, Mac, al, el, ap, da, de, delle, della, di, du, del, der, la, le, lo, van and von. It correctly deals with names which contain apostrophes and hyphens too. ## EXAMPLE FIXES Original Name Case -------- --------- KEITH Keith LEIGH-WILLIAMS Leigh-Williams MCCARTHY McCarthy O'CALLAGHAN O'Callaghan ST. JOHN St. John plus "son (daughter) of" etc. in various languages, e.g.: VON STREIT von Streit VAN DYKE van Dyke AP LLWYD DAFYDD ap Llwyd Dafydd etc. plus names with roman numerals (up to 89, LXXXIX), e.g.: henry viii Henry VIII louis xiv Louis XIV # METHODS - NameCase Takes a scalar, scalarref, array or arrayref, and changes the case of the contents, as appropriate. Essentially a wrapper around nc(). - nc Takes a scalar or scalarref, and change the case of the name in the corresponding string appropriately. # BUGS The module covers the rules that I know of. There are probably a lot more rules, exceptions etc. for "Western"-style languages which could be incorporated. There are probably lots of exceptions and problems - but as a general data 'cleaner' it may be all you need. Use Kim Ryan's [Lingua::EN::NameParse](https://metacpan.org/pod/Lingua%3A%3AEN%3A%3ANameParse) for any really sophisticated name parsing. # AUTHOR 1998-2014 Mark Summerfield 2014-present Barbie 2020- Maintained by Nigel Horne, C<< >> # ACKNOWLEDGEMENTS Thanks to Kim Ryan for his Mc/Mac solution. # COPYRIGHT Copyright (c) Mark Summerfield 1998-2014. All Rights Reserved. Copyright (c) Barbie 2014-2015. All Rights Reserved. This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2. Lingua-EN-NameCase-1.21/t/000755 000765 000024 00000000000 13754220611 015014 5ustar00njhstaff000000 000000 Lingua-EN-NameCase-1.21/t/00use.t000644 000765 000024 00000000415 13753543774 016156 0ustar00njhstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::Most tests => 2; BEGIN { use_ok('Lingua::EN::NameCase') || print 'Bail out!'; } require_ok('Lingua::EN::NameCase') || print 'Bail out!'; diag("Testing Lingua::EN::NameCase $Lingua::EN::NameCase::VERSION, Perl $], $^X"); Lingua-EN-NameCase-1.21/t/10namecase.t000644 000765 000024 00000012432 13753604024 017123 0ustar00njhstaff000000 000000 #!/usr/bin/perl -w use strict; use integer; use Lingua::EN::NameCase qw( NameCase nc ); use Test::More tests => 31; my $debugging = 0; # Set up data for the tests. my @proper_names = ( "Keith", "Leigh-Williams", "McCarthy", "O'Callaghan", "St. John", "von Streit", "van Dyke", "Van", "ap Llwyd Dafydd", "al Fahd", "Al", "el Grecco", "Ben Gurion", "Ben", "da Vinci", "di Caprio", "du Pont", "de Legate", "del Crond", "der Sind", "van der Post", "von Trapp", "la Poisson", "le Figaro", "Mack Knife", "Dougal MacDonald", ); # Mac exceptions my @mac_names = ( "Machin", "Machlin", "Machar", "Mackle", "Macklin", "Mackie", "Macquarie", "Machado", "Macevicius", "Maciulis", "Macias", "MacMurdo", "Mackrell", "Maclin", "McConnachie", ); # Roman numerals my @roman_names = ( "Henry VIII", "Louis III", "Louis XIV", "Charles II", "Fred XLIX", ); push @proper_names, @mac_names, @roman_names; # Set up some module globals. my @lowercase_names = map { lc } @proper_names; my @names = @lowercase_names; my @result; my $name; my $fixed_name; $" = ", " ; #" # Print the original. diag("\tOriginal:\n@lowercase_names.\n") if $debugging; # Test an array without changing the array's contents; print the first result. @result = NameCase( @names ); diag("\tResult:\n@result.\n") if $debugging; diag("\nArray assignment with source array passed by copy...") if $debugging; is_deeply( \@names, \@lowercase_names, 'Array assignment with source array passed by copy' ); is_deeply( \@result, \@proper_names, '.. fixed' ); # Test an array without changing the array's contents; # but pass the array by reference. @result = (); @result = NameCase( \@names ); is_deeply( \@names, \@lowercase_names, 'Array assignment with source array passed by reference' ); is_deeply( \@result, \@proper_names, '.. fixed' ); # Test an array in-place. NameCase( \@names ); is_deeply( \@names, \@proper_names, 'In-place with source array passed by reference' ); # Test a scalar in-place. $name = $lowercase_names[1]; NameCase( \$name ); is( $name, $lowercase_names[1], 'In-place scalar (null operation)' ); # Test a scalar. $name = $lowercase_names[1]; $fixed_name = NameCase( $name ); is( $fixed_name, $proper_names[1], 'Scalar...' ); # Test a literal scalar. $fixed_name = NameCase( "john mcvey" ); is( $fixed_name, "John McVey", 'Literal scalar...' ); # Test a literal array. @result = NameCase( "nancy", "drew" ); is_deeply( \@result, [ "Nancy", "Drew" ], 'Literal array...' ); # Test a scalar. $name = $lowercase_names[1]; $fixed_name = nc $name; is( $fixed_name, $proper_names[1], 'Scalar as list operator...' ); # Test a literal scalar. $fixed_name = nc "john mcvey"; is( $fixed_name, "John McVey", 'Literal scalar as list operator...' ); # Test a reference to a scalar. $name = $lowercase_names[1]; $fixed_name = nc( \$name ); is( $name, $lowercase_names[1],'Reference to a scalar using nc...' ); is( $fixed_name, $proper_names[1],'.. fixed' ); # Test a scalar in an array context. $name = $lowercase_names[1]; @result = nc $name; is( $result[0], $proper_names[1], 'Scalar in a list context using nc...'); # Test a reference to a scalar in an array context. $name = $lowercase_names[1]; @result = nc \$name; print "Reference to a scalar in a list context using nc..." if $debugging; print "" . ( $name eq $lowercase_names[1] ? "ok" : "not ok\a" ) if $debugging; is( $name, $lowercase_names[1], 'Reference to a scalar in a list context using nc...'); is( $result[0], $proper_names[1], '.. fixed'); # Test a reference to a scalar. $name = $lowercase_names[1]; $fixed_name = NameCase( \$name ); is( $name, $lowercase_names[1], 'Reference to a scalar using NameCase...' ); is( $fixed_name, $proper_names[1], '.. fixed' ); # Test a scalar in an array context. $name = $lowercase_names[1]; @result = NameCase $name; is( $result[0], $proper_names[1], 'Scalar in a list context using NameCase...' ); # Test a reference to a scalar in an array context. $name = $lowercase_names[1]; @result = NameCase \$name; is( $name, $lowercase_names[1], 'Reference to a scalar in a list context using NameCase...' ); is( $result[0], $proper_names[1], '.. fixed'); $Lingua::EN::NameCase::SPANISH = 1; is( nc( 'El Paso' ), 'El Paso', 'spanish' ); is( nc( 'La Luna' ), 'La Luna', 'spanish' ); $Lingua::EN::NameCase::SPANISH = 0; is( nc( 'El Paso' ), 'el Paso', 'not spanish' ); is( nc( 'La Luna' ), 'la Luna', 'not spanish' ); $Lingua::EN::NameCase::ROMAN = 1; is( nc( 'Na Li' ), 'Na LI', 'roman numerals' ); $Lingua::EN::NameCase::ROMAN = 0; is( nc( 'Na Li' ), 'Na Li', 'not roman numerals' ); $Lingua::EN::NameCase::POSTNOMINAL = 1; is( nc( 'Barbie PHD' ), 'Barbie PhD', 'post nominal initials' ); $Lingua::EN::NameCase::POSTNOMINAL = 0; is( nc( 'Barbie PHD' ), 'Barbie Phd', 'not post nominal initials' ); $Lingua::EN::NameCase::HEBREW = 1; is( nc( 'Aharon BEN Amram Ha-Kohein' ), 'Aharon ben Amram Ha-Kohein', 'hebrew' ); $Lingua::EN::NameCase::HEBREW = 0; is( nc( 'Aharon BEN Amram Ha-Kohein' ), 'Aharon Ben Amram Ha-Kohein', 'not hebrew' ); Lingua-EN-NameCase-1.21/t/11examples.t000644 000765 000024 00000001633 13753543344 017176 0ustar00njhstaff000000 000000 #!/usr/bin/perl use strict; use Lingua::EN::NameCase 'nc'; use Test::More tests => 12; my %tests = ( q{DR SARAH BEETLE} => q{Dr Sarah Beetle}, q{june O'LEARY} => q{June O'Leary}, q{MICHAEL JOHN JACOBS JR} => q{Michael John Jacobs Jr}, q{MR. jon whitacre iii} => q{Mr. Jon Whitacre III}, q{MARY BETH DAVIDSON MD} => q{Mary Beth Davidson MD}, q{MS LAURA CONLEY-ROSE} => q{Ms Laura Conley-Rose}, q{LAURA&DAVID SMITH} => q{Laura&David Smith}, q{ESTATE OF LAURA JONES} => q{Estate Of Laura Jones}, q{MS MS. LAURA J BYRD} => q{Ms Ms. Laura J Byrd}, q{ben mcgrath} => q{Ben McGrath}, q{AHARON BEN AMRAM HA-KOHEIN} => q{Aharon ben Amram Ha-Kohein}, q{MIRIAM BAT RIVKAH} => q{Miriam bat Rivkah}, ); for my $test (keys %tests) { is( nc($test), $tests{$test}); } Lingua-EN-NameCase-1.21/t/12badcalls.t000644 000765 000024 00000001276 13753543344 017131 0ustar00njhstaff000000 000000 #!/usr/bin/perl -w use strict; use Lingua::EN::NameCase qw( NameCase nc ); use Test::More tests => 7; eval { NameCase() }; like($@,qr/NameCase only accepts/,'.. missing parameters, no error'); eval { NameCase( { 'trent' => 'reznor' } ) }; like($@,qr/Usage/,'.. hash not scalar(ref) or array(ref)'); my $res = 'test'; eval { $res = nc() }; is($@,'','.. missing parameters, no error'); is($res,undef,'.. missing parameters, no result'); eval { nc( { 'trent' => 'reznor' } ) }; like($@,qr/Usage/,'.. hash not scalar(ref)'); eval { nc( [ 'trent', 'reznor' ] ) }; like($@,qr/Usage/,'.. array not scalar(ref)'); eval { nc( 'trent', 'reznor' ) }; like($@,qr/Usage/,'.. mulitple strings not supported'); Lingua-EN-NameCase-1.21/t/90podtest.t000644 000765 000024 00000000450 13754067704 017047 0ustar00njhstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTHOR_TESTING} ); eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Lingua-EN-NameCase-1.21/t/91podcover.t000644 000765 000024 00000000543 13754070167 017207 0ustar00njhstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTHOR_TESTING} ); eval "use Test::Pod::Coverage 0.08"; plan skip_all => "Test::Pod::Coverage 0.08 required for testing POD coverage" if $@; all_pod_coverage_ok({ also_private => ['new'] }); Lingua-EN-NameCase-1.21/t/94metatest.t000644 000765 000024 00000001777 13754104772 017231 0ustar00njhstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTHOR_TESTING} ); eval 'use Test::CPAN::Meta'; plan skip_all => 'Test::CPAN::Meta required for testing META.yml' if $@; plan 'no_plan'; exit; # Don't use our own META.yml file my $meta = meta_spec_ok(undef,undef,@_); use Lingua::EN::NameCase; my $version = $Lingua::EN::NameCase::VERSION; is($meta->{version},$version, 'META.yml distribution version matches'); if($meta->{provides}) { for my $mod (keys %{$meta->{provides}}) { is($meta->{provides}{$mod}{version},$version, "META.yml entry [$mod] version matches distribution version"); eval "require $mod"; my $VERSION = '$' . $mod . '::VERSION'; my $v = eval "$VERSION"; is($meta->{provides}{$mod}{version},$v, "META.json entry [$mod] version matches module version"); isnt($meta->{provides}{$mod}{version},0); } } Lingua-EN-NameCase-1.21/t/95changedate.t000644 000765 000024 00000002345 13753604024 017451 0ustar00njhstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More; use IO::File; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTHOR_TESTING} ); my $fh = IO::File->new('Changes','r') or plan skip_all => "Cannot open Changes file"; plan 'no_plan'; use Lingua::EN::NameCase; my $version = $Lingua::EN::NameCase::VERSION; my $latest = 0; while(<$fh>) { next unless(m!^\d!); $latest = 1 if(m!^$version!); # 2012-08-26T01:02 or 2012-08-26T01:02:03 or 2012-08-26T01:02:03.04 or 2012-08-26T01:02+01:00 like($_, qr! \d[\d._]+\s+ # version ( \d{4}-\d{2}-\d{2} # 2012-08-26 - YYYY-MM-DD ( T\d{2}:\d{2} # T01:02 - Thh:mm ( :\d{2} # :02 - :ss ( \.\d+ # .2 - .ss (microseconds) )? )? ( (Z|[-+]\d+:\d+) # +01:00 - timezone )? )? ) !x,'... version has a date'); } is($latest,1,'... latest version not listed'); Lingua-EN-NameCase-1.21/t/96metatest.t000644 000765 000024 00000002025 13754104754 017216 0ustar00njhstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTHOR_TESTING} ); eval 'use Test::CPAN::Meta::JSON'; plan skip_all => 'Test::CPAN::Meta::JSON required for testing META.json files' if $@; plan 'no_plan'; exit; # Don't use our own META.json file my $meta = meta_spec_ok(undef,undef,@_); use Lingua::EN::NameCase; my $version = $Lingua::EN::NameCase::VERSION; is($meta->{version},$version, 'META.json distribution version matches'); if($meta->{provides}) { for my $mod (keys %{$meta->{provides}}) { is($meta->{provides}{$mod}{version},$version, "META.json entry [$mod] version matches distribution version"); eval "require $mod"; my $VERSION = '$' . $mod . '::VERSION'; my $v = eval "$VERSION"; is($meta->{provides}{$mod}{version},$v, "META.json entry [$mod] version matches module version"); isnt($meta->{provides}{$mod}{version},0); } } Lingua-EN-NameCase-1.21/t/eol.t000644 000765 000024 00000000530 13753604024 015761 0ustar00njhstaff000000 000000 use strict; use warnings; use Test::Most; BEGIN { if($ENV{AUTHOR_TESTING}) { eval { require Test::EOL; }; if($@) { plan(skip_all => 'Test::EOL not installed'); } else { import Test::EOL; all_perl_files_ok({ trailing_whitespace => 1 }); } } else { plan(skip_all => 'Author tests not required for installation'); } } Lingua-EN-NameCase-1.21/t/links.t000644 000765 000024 00000000473 13754104515 016331 0ustar00njhstaff000000 000000 #!perl -w use strict; use warnings; use Test::Most; if(not $ENV{AUTHOR_TESTING}) { plan(skip_all => 'Author tests not required for installation'); } eval "use Test::Pod::LinkCheck"; if($@) { plan skip_all => 'Test::Pod::LinkCheck required for testing POD'; } else { Test::Pod::LinkCheck->new->all_pod_ok(); } Lingua-EN-NameCase-1.21/t/no404s.t000644 000765 000024 00000000441 13754104521 016230 0ustar00njhstaff000000 000000 #!perl -wT use strict; use warnings; use Test::Most; if(not $ENV{AUTHOR_TESTING}) { plan(skip_all => 'Author tests not required for installation'); } eval "use Test::Pod::No404s"; if($@) { plan skip_all => 'Test::Pod::No404s required for testing POD'; } else { all_pod_files_ok(); } Lingua-EN-NameCase-1.21/t/pod-cm.t000644 000765 000024 00000000364 13753604024 016366 0ustar00njhstaff000000 000000 #!/usr/bin/perl -w use strict; use warnings; use Test::Most; eval 'use Test::Pod::Spelling::CommonMistakes'; if($@) { plan skip_all => 'Test::Pod::Spelling::CommonMistakes required for testing POD spelling'; } else { all_pod_files_ok(); } Lingua-EN-NameCase-1.21/t/pod.t000644 000765 000024 00000000514 13753604024 015766 0ustar00njhstaff000000 000000 #!perl -T use strict; use warnings; use Test::Most; if(not $ENV{AUTHOR_TESTING}) { plan(skip_all => 'Author tests not required for installation'); } # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan(skip_all => "Test::Pod $min_tp required for testing POD") if $@; all_pod_files_ok(); Lingua-EN-NameCase-1.21/t/vars.t000644 000765 000024 00000000471 13754067564 016176 0ustar00njhstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::Most; if(not $ENV{AUTHOR_TESTING}) { plan(skip_all => 'Author tests not required for installation'); } eval 'use Test::Vars'; plan(skip_all => 'Test::Vars required for detecting unused variables') if $@; all_vars_ok(ignore_vars => { '$self' => 0 }); Lingua-EN-NameCase-1.21/lib/Lingua/000755 000765 000024 00000000000 13754220611 016536 5ustar00njhstaff000000 000000 Lingua-EN-NameCase-1.21/lib/Lingua/EN/000755 000765 000024 00000000000 13754220611 017040 5ustar00njhstaff000000 000000 Lingua-EN-NameCase-1.21/lib/Lingua/EN/NameCase.pm000644 000765 000024 00000025473 13754220440 021065 0ustar00njhstaff000000 000000 package Lingua::EN::NameCase; =head1 NAME Lingua::EN::NameCase - Correctly case a person's name from UPERCASE or lowcase =cut use warnings; use strict; use locale; use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK $HEBREW $SPANISH $ROMAN $POSTNOMINAL ); =head1 VERSION Version 1.21 =cut our $VERSION = '1.21'; =head1 SYNOPSIS # Working with scalars; complementing lc and uc. use Lingua::EN::NameCase qw( nc ); $FixedCasedName = nc( $OriginalName ); $FixedCasedName = nc( \$OriginalName ); # Working with arrays or array references. use Lingua::EN::NameCase 'NameCase'; $FixedCasedName = NameCase( $OriginalName ); @FixedCasedNames = NameCase( @OriginalNames ); $FixedCasedName = NameCase( \$OriginalName ); @FixedCasedNames = NameCase( \@OriginalNames ); NameCase( \@OriginalNames ) ; # In-place. # NameCase will not change a scalar in-place, i.e. NameCase( \$OriginalName ) ; # WRONG: null operation. $Lingua::EN::NameCase::SPANISH = 1; # Now 'El' => 'El' instead of (default) Greek 'El' => 'el'. # Now 'La' => 'La' instead of (default) French 'La' => 'la'. $Lingua::EN::NameCase::HEBREW = 0; # Now 'Aharon BEN Amram Ha-Kohein' => 'Aharon Ben Amram Ha-Kohein' # instead of (default) => 'Aharon ben Amram Ha-Kohein'. $Lingua::EN::NameCase::ROMAN = 0; # Now 'Li' => 'Li' instead of (default) 'Li' => 'LI'. $Lingua::EN::NameCase::POSTNOMINAL = 0; # Now 'PHD' => 'PhD' instead of (default) 'PHD' => 'Phd'. =head1 DESCRIPTION Forenames and surnames are often stored either wholly in UPPERCASE or wholly in lowercase. This module allows you to convert names into the correct case where possible. Although forenames and surnames are normally stored separately if they do appear in a single string, whitespace separated, NameCase and nc deal correctly with them. NameCase currently correctly name cases names which include any of the following: Mc, Mac, al, el, ap, da, de, delle, della, di, du, del, der, la, le, lo, van and von. It correctly deals with names which contain apostrophes and hyphens too. =head2 EXAMPLE FIXES Original Name Case -------- --------- KEITH Keith LEIGH-WILLIAMS Leigh-Williams MCCARTHY McCarthy O'CALLAGHAN O'Callaghan ST. JOHN St. John plus "son (daughter) of" etc. in various languages, e.g.: VON STREIT von Streit VAN DYKE van Dyke AP LLWYD DAFYDD ap Llwyd Dafydd etc. plus names with roman numerals (up to 89, LXXXIX), e.g.: henry viii Henry VIII louis xiv Louis XIV =cut #-------------------------------------------------------------------------- # Modules use Carp; use Exporter(); @ISA = qw( Exporter ); @EXPORT = qw( nc ); @EXPORT_OK = qw( NameCase nc ); #-------------------------------------------------------------------------- # Variables $HEBREW = 1; $SPANISH = 0; $ROMAN = 1; $POSTNOMINAL = 1; my @POST_NOMINAL_INITIALS = qw( VC GC KG LG KT LT KP GCB OM GCSI GCMG GCIE GCVO GBE CH KCB DCB KCSI KCMG DCMG KCIE KCVO DCVO KBE DBE CB CSI CMG CIE CVO CBE DSO LVO OBE ISO MVO MBE IOM CGC RRC DSC MC DFC AFC ARRC OBI DCM CGM GM IDSM DSM MM DFM AFM SGM IOM CPM QGM RVM BEM QPM QFSM QAM CPM MSM ERD VD TD UD ED RD VRD AE PC ADC QHP QHS QHDS QHNS QHC SCJ J LJ QS SL QC KC JP DL MP MSP MSYP AM AM MLA MEP DBEnv DConstMgt DREst EdD DPhil PhD DLitt DSocSci MD EngD DD LLD DProf MA MArch MAnth MSc MMORSE MMath MMathStat MPharm MPhil MSc MSci MSt MRes MEng MChem MBiochem MSocSc MMus LLM BCL MPhys MComp MAcc MFin MBA MPA MEd MEP MEnt MCGI MGeol MLitt MEarthSc MClinRes BA BSc LLB BEng MBChB FdA FdSc FdEng PgDip PgD PgCert PgC PgCLTHE AUH AKC AUS HNC HNCert HND HNDip DipHE Dip OND CertHE ACSM MCSM DIC AICSM ARSM ARCS LLB LLM BCL MJur DPhil PhD LLD DipLP FCILEx GCILEx ACILEx CQSW DipSW BSW MSW FCILT CMILT MILT CPL CTP CML PLS CTL DLP PLog EJLog ESLog EMLog JrLog Log SrLog BArch MArch ARB RIBA RIAS RIAI RSAW MB BM BS BCh BChir MRCS FRCS MS MCh. MRCP FRCP MRCPCH FRCPCH MRCPath MFPM FFPM BDS MRCPsych FRCPsych MRCOG FRCOG MCEM FCEM FRCA FFPMRCA MRCGP FRCGP BSc MScChiro MChiro MSc DC LFHOM MFHOM FFHOM FADO FBDO FCOptom MCOptom MOst DPT MCSP FCSP. SROT MSCR FSCR. CPhT RN VN RVN BVSc BVetMed VetMB BVM&S MRCVS FRCVS FAWM PGCAP PGCHE PGCE PGDE BEd NPQH QTS CSci CSciTeach RSci RSciTech CEng IEng EngTech ICTTech DEM MM CMarEng CMarSci CMarTech IMarEng MarEngTech RGN SRN RMN RSCN SEN EN RNMH RN RM RN1 RNA RN2 RN3 RNMH RN4 RN5 RNLD RN6 RN8 RNC RN7 RN9 RHV RSN ROH RFHN SPAN SPMH SPCN SPLD SPHP SCHM SCLD SPCC SPDN V100 V200 V300 LPE MSc ); #-------------------------------------------------------------------------- # Functions =head2 NameCase Takes a scalar, scalarref, array or arrayref, and changes the case of the contents, as appropriate. Essentially a wrapper around nc(). =cut sub NameCase { croak "Usage: \$SCALAR|\@ARRAY = NameCase [\\]\$SCALAR|\@ARRAY" if ref $_[0] and ( ref $_[0] ne 'ARRAY' and ref $_[0] ne 'SCALAR' ); local( $_ ); if( wantarray and ( scalar @_ > 1 or ref $_[0] eq 'ARRAY' ) ) { # We have received an array or array reference in a list context # so we will return an array. map { nc( $_ ) } @{ ref( $_[0] ) ? $_[0] : \@_ }; } elsif( ref $_[0] eq 'ARRAY' ) { # We have received an array reference in a scalar or void context # so we will work on the array in-place. foreach ( @{ $_[0] } ) { $_ = nc( $_ ); } } elsif( ref $_[0] eq 'SCALAR' ) { # We don't work on scalar references in-place; we take the value # and return a name-cased copy. nc( ${ $_[0] } ); } elsif( scalar @_ == 1 ) { # We've received a scalar: we return a name-cased copy. nc( $_[0] ); } else { croak "NameCase only accepts a single scalar, array or array ref"; } } =head2 nc Takes a scalar or scalarref, and change the case of the name in the corresponding string appropriately. =cut sub nc { croak "Usage: nc [[\\]\$SCALAR]" if scalar @_ > 1 or ( ref $_[0] and ref $_[0] ne 'SCALAR' ); local( $_ ) = @_ if @_; $_ = ${$_} if ref( $_ ) ; # Replace reference with value. return $_ unless($_); $_ = lc ; # Lowercase the lot. s{ \b (\w) }{\u$1}gx; # Uppercase first letter of every word. s{ (\'\w) \b }{\L$1}gx; # Lowercase 's. # Name case Mcs and Macs - taken straight from NameParse.pm incl. comments. # Exclude names with 1-2 letters after prefix like Mack, Macky, Mace # Exclude names ending in a,c,i,o, or j are typically Polish or Italian if ( /\bMac[A-Za-z]{2,}[^aciozj]\b/ or /\bMc/ ) { s/\b(Ma?c)([A-Za-z]+)/$1\u$2/g; # Now correct for "Mac" exceptions s/\bMacEvicius/Macevicius/g; # Lithuanian s/\bMacHado/Machado/g; # Portuguese s/\bMacHar/Machar/g; s/\bMacHin/Machin/g; s/\bMacHlin/Machlin/g; s/\bMacIas/Macias/g; s/\bMacIulis/Maciulis/g; s/\bMacKie/Mackie/g; s/\bMacKle/Mackle/g; s/\bMacKlin/Macklin/g; s/\bMacQuarie/Macquarie/g; s/\bMacOmber/Macomber/g; s/\bMacIn/Macin/g; s/\bMacKintosh/Mackintosh/g; s/\bMacKen/Macken/g; s/\bMacHen/Machen/g; s/\bMacisaac/MacIsaac/g; s/\bMacHiel/Machiel/g; s/\bMacIol/Maciol/g; s/\bMacKell/Mackell/g; s/\bMacKlem/Macklem/g; s/\bMacKrell/Mackrell/g; s/\bMacLin/Maclin/g; s/\bMacKey/Mackey/g; s/\bMacKley/Mackley/g; s/\bMacHell/Machell/g; s/\bMacHon/Machon/g; } s/Macmurdo/MacMurdo/g; # Fixes for "son (daughter) of" etc. in various languages. s{ \b Al(?=\s+\w) }{al}gx; # al Arabic or forename Al. s{ \b Ap \b }{ap}gx; # ap Welsh. # search for: followed by ben # without first (?<=\S\s), first name of 'ben jones' remains lowercase s{ (?<=\S\s)\bBen(?=\s+\w) }{ben}gx if $HEBREW; # ben Hebrew or forename Ben. s{ (?<=\S\s)\bBat(?=\s+\w) }{bat}gx if $HEBREW; # bat Hebrew or forename Bat. s{ \b Dell([ae])\b }{dell$1}gx; # della and delle Italian. s{ \b D([aeiu]) \b }{d$1}gx; # da, de, di Italian; du French. s{ \b De([lr]) \b }{de$1}gx; # del Italian; der Dutch/Flemish. s{ \b El \b }{el}gx unless $SPANISH; # el Greek or El Spanish. s{ \b La \b }{la}gx unless $SPANISH; # la French or La Spanish. s{ \b L([eo]) \b }{l$1}gx; # lo Italian; le French. s{ \b Van(?=\s+\w) }{van}gx; # van German or forename Van. s{ \b Von \b }{von}gx; # von Dutch/Flemish if($ROMAN) { # Fixes for roman numeral names, e.g. Henry VIII, up to 89, LXXXIX s{ \b ( (?: [Xx]{1,3} | [Xx][Ll] | [Ll][Xx]{0,3} )? (?: [Ii]{1,3} | [Ii][VvXx] | [Vv][Ii]{0,3} )? ) \b }{\U$1}gx; } if($POSTNOMINAL) { # post-nominal initials for my $pni (@POST_NOMINAL_INITIALS) { s{ \b ($pni) $}{$pni}ix; } } $_; } =head1 BUGS The module covers the rules that I know of. There are probably a lot more rules, exceptions etc. for "Western"-style languages which could be incorporated. There are probably lots of exceptions and problems - but as a general data 'cleaner' it may be all you need. Use Kim Ryan's L for any really sophisticated name parsing. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Lingua::EN::NameCase You can also look for information at: =over 4 =item * MetaCPAN L =item * RT: CPAN's request tracker L =item * CPANTS L =item * CPAN Testers' Matrix L =item * CPAN Ratings L =item * CPAN Testers Dependencies L =back =head1 AUTHOR 1998-2014 Mark Summerfield 2014-present Barbie 2020- Maintained by Nigel Horne, C<< >> =head1 ACKNOWLEDGEMENTS Thanks to Kim Ryan for his Mc/Mac solution. =head1 COPYRIGHT Copyright (c) Mark Summerfield 1998-2014. All Rights Reserved. Copyright (c) Barbie 2014-2015. All Rights Reserved. This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2. =cut 1;