r67642 - in /trunk/liblingua-en-nameparse-perl: Changes MANIFEST META.yml debian/changelog lib/Lingua/EN/NameGrammar.pm lib/Lingua/EN/NameParse.pm lib/Lingua/EN/NameParse/ t/rules.t
periapt-guest at users.alioth.debian.org
periapt-guest at users.alioth.debian.org
Fri Jan 21 22:18:56 UTC 2011
Author: periapt-guest
Date: Fri Jan 21 22:18:45 2011
New Revision: 67642
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=67642
Log:
New upstream release
Added:
trunk/liblingua-en-nameparse-perl/lib/Lingua/EN/NameParse/
- copied from r67640, branches/upstream/liblingua-en-nameparse-perl/current/lib/Lingua/EN/NameParse/
Removed:
trunk/liblingua-en-nameparse-perl/lib/Lingua/EN/NameGrammar.pm
Modified:
trunk/liblingua-en-nameparse-perl/Changes
trunk/liblingua-en-nameparse-perl/MANIFEST
trunk/liblingua-en-nameparse-perl/META.yml
trunk/liblingua-en-nameparse-perl/debian/changelog
trunk/liblingua-en-nameparse-perl/lib/Lingua/EN/NameParse.pm
trunk/liblingua-en-nameparse-perl/t/rules.t
Modified: trunk/liblingua-en-nameparse-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblingua-en-nameparse-perl/Changes?rev=67642&op=diff
==============================================================================
--- trunk/liblingua-en-nameparse-perl/Changes (original)
+++ trunk/liblingua-en-nameparse-perl/Changes Fri Jan 21 22:18:45 2011
@@ -1,4 +1,11 @@
Revision history for Perl CPAN module Lingua::En::NameParse
+
+1.29 23 Jan 2011
+ Corrected documentation of case_components module, thanks to John Hansen
+ Removed invalid space after /Pilot Officer/ in extended titles grammar, thanks to John Hansen
+ Added the 'Mr_J_Adam_Smith' name type, thanks to John Hansen
+ Added the 'John' name type, thanks to Graham Seamen
+ Moved NameGrammar.pm to Lingua::EN::NameParse::Grammar name space
1.28 3 Jan 2011
Added more extended titles including Pilot Officer, Count, Duke, Dutchess, Marquess (thanks to Hugh Myers)
Modified: trunk/liblingua-en-nameparse-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblingua-en-nameparse-perl/MANIFEST?rev=67642&op=diff
==============================================================================
--- trunk/liblingua-en-nameparse-perl/MANIFEST (original)
+++ trunk/liblingua-en-nameparse-perl/MANIFEST Fri Jan 21 22:18:45 2011
@@ -4,7 +4,7 @@
Makefile.PL
examples/demo.pl
lib/Lingua/EN/NameParse.pm
-lib/Lingua/EN/NameGrammar.pm
+lib/Lingua/EN/NameParse/Grammar.pm
surname_prefs.txt
t/main.t
t/rules.t
Modified: trunk/liblingua-en-nameparse-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblingua-en-nameparse-perl/META.yml?rev=67642&op=diff
==============================================================================
--- trunk/liblingua-en-nameparse-perl/META.yml (original)
+++ trunk/liblingua-en-nameparse-perl/META.yml Fri Jan 21 22:18:45 2011
@@ -1,14 +1,22 @@
--- #YAML:1.0
-name: Lingua-EN-NameParse
-version: 1.28
-abstract: Manipulate peoples names, titles and initials
-license: perl
-author:
+name: Lingua-EN-NameParse
+version: 1.29
+abstract: Manipulate peoples names, titles and initials
+author:
- Kim Ryan
-generated_by: ExtUtils::MakeMaker version 6.42_01
-distribution_type: module
-requires:
- Parse::RecDescent: 0
+license: perl
+distribution_type: module
+configure_requires:
+ ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
+requires:
+ Parse::RecDescent: 0
+no_index:
+ directory:
+ - t
+ - inc
+generated_by: ExtUtils::MakeMaker version 6.56
meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.3.html
- version: 1.3
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
Modified: trunk/liblingua-en-nameparse-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblingua-en-nameparse-perl/debian/changelog?rev=67642&op=diff
==============================================================================
--- trunk/liblingua-en-nameparse-perl/debian/changelog (original)
+++ trunk/liblingua-en-nameparse-perl/debian/changelog Fri Jan 21 22:18:45 2011
@@ -1,3 +1,9 @@
+liblingua-en-nameparse-perl (1.29-1) UNRELEASED; urgency=low
+
+ * New upstream release
+
+ -- Nicholas Bamber <nicholas at periapt.co.uk> Fri, 21 Jan 2011 22:20:28 +0000
+
liblingua-en-nameparse-perl (1.28-1) unstable; urgency=low
[ Russ Allbery ]
Modified: trunk/liblingua-en-nameparse-perl/lib/Lingua/EN/NameParse.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblingua-en-nameparse-perl/lib/Lingua/EN/NameParse.pm?rev=67642&op=diff
==============================================================================
--- trunk/liblingua-en-nameparse-perl/lib/Lingua/EN/NameParse.pm (original)
+++ trunk/liblingua-en-nameparse-perl/lib/Lingua/EN/NameParse.pm Fri Jan 21 22:18:45 2011
@@ -107,12 +107,13 @@
J_Adam_Smith
John_Smith
A_Smith
-
+ John
Precursors and suffixes are only applied to the following formats:
Mr_John_Adam_Smith
Mr_John_A_Smith
+ Mr_J_Adam_Smith
Mr_John_Smith
Mr_John_Smith
Mr_A_Smith
@@ -274,7 +275,7 @@
=head2 case_components
- %my_name = $name->components;
+ %my_name = $name->case_components;
$cased_surname = $my_name{surname_1};
@@ -391,22 +392,24 @@
=item type
The type of format a name is in, as one of the following strings:
-
- Mr_A_Smith_&_Ms_B_Jones
- Mr_&_Ms_A_&_B_Smith
- Mr_A_&_Ms_B_Smith
- Mr_&_Ms_A_Smith
- Mr_A_&_B_Smith
- Mr_John_Adam_Smith
- Mr_John_A_Smith
- Mr_John_Smith
- Mr_A_Smith
- John_Adam_Smith
- John_A_Smith
- J_Adam_Smith
- John_Smith
- A_Smith
- unknown
+
+ Mr_A_Smith_&_Ms_B_Jones
+ Mr_&_Ms_A_&_B_Smith
+ Mr_A_&_Ms_B_Smith
+ Mr_&_Ms_A_Smith
+ Mr_A_&_B_Smith
+ Mr_John_Adam_Smith
+ Mr_John_A_Smith
+ Mr_J_Adam_Smith
+ Mr_John_Smith
+ Mr_A_Smith
+ John_Adam_Smith
+ John_A_Smith
+ J_Adam_Smith
+ John_Smith
+ A_Smith
+ John
+ unknown
=item non_matching
@@ -523,7 +526,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2008 Kim Ryan. All rights reserved.
+Copyright (c) 2011 Kim Ryan. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.4 or,
@@ -539,13 +542,13 @@
use strict;
use warnings;
-use Lingua::EN::NameGrammar;
+use Lingua::EN::NameParse::Grammar;
use Parse::RecDescent;
use Exporter;
use vars qw (@ISA @EXPORT_OK);
-our $VERSION = '1.28';
+our $VERSION = '1.29';
@ISA = qw(Exporter);
@EXPORT_OK = qw(&clean &case_surname);
@@ -568,17 +571,10 @@
my $current_key;
foreach my $current_key (keys %args)
{
- if ( $current_key eq 'salutation' or $current_key eq 'sal_default' )
- {
- $name->{$current_key} = &_case_word($args{$current_key});
- }
- else
- {
- $name->{$current_key} = $args{$current_key};
- }
- }
-
- my $grammar = &Lingua::EN::NameGrammar::_create($name);
+ $name->{$current_key} = $args{$current_key};
+ }
+
+ my $grammar = &Lingua::EN::NameParse::Grammar::_create($name);
$name->{parse} = new Parse::RecDescent($grammar);
return ($name);
@@ -728,7 +724,8 @@
'John_A_Smith' => ['precursor','given_name_1','initials_1','surname_1','suffix'],
'J_Adam_Smith' => ['precursor','initials_1','middle_name','surname_1','suffix'],
'John_Smith' => ['precursor','given_name_1','surname_1','suffix'],
- 'A_Smith' => ['precursor','initials_1','surname_1','suffix']
+ 'A_Smith' => ['precursor','initials_1','surname_1','suffix'],
+ 'John' => ['given_name_1']
);
# only include names with a single surname
@@ -1065,7 +1062,12 @@
push(@greeting,$sal_default);
}
}
- }
+ }
+ else
+ {
+ warn "Invalid sal_type : ", $sal_type;
+ push(@greeting,$sal_default);
+ }
}
return(join(' ', at greeting));
}
@@ -1119,16 +1121,24 @@
# PRIVATE METHODS
#-------------------------------------------------------------------------------
-# Check that common reserved word (as found in company names) do not appear
+
sub _pre_parse
{
my $name = shift;
-
+ # Check that common reserved word (as found in company names) do not appear
if ( $name->{input_string} =~
/\bPty\.? Ltd\.?$|\bLtd\.?$|\bPLC$|Association|Department|National|Society/i )
{
$name->{error} = 1;
$name->{properties}{non_matching} = $name->{input_string};
+ }
+
+ # For the case of a single name such as 'Voltaire' we need to add a trailing space
+ # to the input string. This is because the grammar tree expects a terminator (the space)
+ # optionally followed by other productions or non matching text
+ if ( $name->{input_string} =~ /^[A-Z]{2,}(\-)?[A-Z]{0,}$/i )
+ {
+ $name->{input_string} .= ' ';
}
return($name);
@@ -1141,6 +1151,9 @@
{
my $name = shift;
+ # $::RD_TRACE = 1; # for debugging RecDescent output
+ # Use Parse::RecDescent to do the parsing. 'full_name' is a label for the complete grammar tree
+ # defined in Lingua::EN::NameParse::Grammar
my $parsed_name = $name->{parse}->full_name($name->{input_string});
# Place components into a separate hash, so they can be easily returned
Modified: trunk/liblingua-en-nameparse-perl/t/rules.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblingua-en-nameparse-perl/t/rules.t?rev=67642&op=diff
==============================================================================
--- trunk/liblingua-en-nameparse-perl/t/rules.t (original)
+++ trunk/liblingua-en-nameparse-perl/t/rules.t Fri Jan 21 22:18:45 2011
@@ -4,7 +4,7 @@
#------------------------------------------------------------------------------
use strict;
-use Test::Simple tests => 18;
+use Test::Simple tests => 20;
use Lingua::EN::NameParse;
my %args =
@@ -67,6 +67,11 @@
%props = $name->properties;
ok( $props{type} eq 'Mr_John_Adam_Smith', 'Mr_John_Adam_Smith format');
+$input = "MR J FITZGERALD KENNEDY";
+$name->parse($input);
+%props = $name->properties;
+ok( $props{type} eq 'Mr_J_Adam_Smith', 'Mr_J_Adam_Smith format');
+
$input = "MR JOHN F KENNEDY";
$name->parse($input);
%props = $name->properties;
@@ -107,4 +112,9 @@
%props = $name->properties;
ok( $props{type} eq 'A_Smith', 'A_Smith format');
+$input = "Voltaire";
+$name->parse($input);
+%props = $name->properties;
+ok( $props{type} eq 'John', 'John format');
+
More information about the Pkg-perl-cvs-commits
mailing list