This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 4819d3a Allow for nicknames when matching
4819d3a is described below
commit 4819d3a0e2937bd394e45dc70874a8a509f55831
Author: Sebb <[email protected]>
AuthorDate: Sun Jun 20 16:20:04 2021 +0100
Allow for nicknames when matching
---
lib/whimsy/asf/person.rb | 37 ++++++++++++++++++++++++++++++++++++-
www/members/ldap-namecheck.cgi | 2 +-
www/secretary/ldap-names.cgi | 2 +-
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/lib/whimsy/asf/person.rb b/lib/whimsy/asf/person.rb
index 2a6d8a9..e98ee25 100644
--- a/lib/whimsy/asf/person.rb
+++ b/lib/whimsy/asf/person.rb
@@ -141,7 +141,7 @@ module ASF
result = {'cn' => name}
result['title'] = words.shift if words.first == 'Dr.' or words.first ==
'Dr'
result['initials'] = []
- while words.first =~ %r{^[A-Z]\.?$}
+ while words.first =~ %r{^[A-Z]\.$}
result['initials'] << words.shift
end
if words.last =~ /^Ph\.D\.?/
@@ -164,6 +164,41 @@ module ASF
result
end
+ # Name equivalences
+ names = [
+ %w(Alex Alexander Alexandru),
+ %w(Andrew Andy),
+ %w(William Bill),
+ %w(Chris Christopher),
+ %w(Joe Joey),
+ %w(Dan Daniel),
+ %w(David Dave),
+ %w(Don Donald),
+ %w(Greg Gregory),
+ %w(Matt Matthew),
+ %w(Mike Michael Mick),
+ %w(Nikoloai Nickolay),
+ %w(Phil Philip),
+ %w(Rob Robbie Robert),
+ %w(Stephen Steve Steven),
+ %w(Tom Thomas),
+ %w(Tomek Tomasz),
+ %w(Zach Zachary),
+ ]
+ NAMEHASH = Hash.new
+ names.each_with_index do |list, index|
+ list.each do |name|
+ NAMEHASH[name] = index
+ end
+ end
+ def self.names_equivalent?(one, two)
+ # index cannot be -1, cannot match if missing entries are set to -1 or
nil
+ return one == two ||
+ (NAMEHASH[one] || -1) == NAMEHASH[two] ||
+ one.start_with?("#{two} ") || two.start_with?("#{one }") ||
+ (NAMEHASH[one.split(' ').first] || -1) == NAMEHASH[two.split('
').first]
+ end
+
# DRAFT
# return name suitable for a filename stem
# Should normally be applied to the legal name
diff --git a/www/members/ldap-namecheck.cgi b/www/members/ldap-namecheck.cgi
index de6d255..d5559ef 100755
--- a/www/members/ldap-namecheck.cgi
+++ b/www/members/ldap-namecheck.cgi
@@ -72,7 +72,7 @@ _html do
unused = parse['unused']
_initials = parse['initials']
- givenOK = (new_given == given)
+ givenOK = ASF::Person.names_equivalent?(new_given, given)
badGiven += 1 unless givenOK
snOK = (new_sn == p.sn)
diff --git a/www/secretary/ldap-names.cgi b/www/secretary/ldap-names.cgi
index e8e5bf4..48f4fc9 100755
--- a/www/secretary/ldap-names.cgi
+++ b/www/secretary/ldap-names.cgi
@@ -126,7 +126,7 @@ _html do
unused = parse['unused']
_initials = parse['initials']
- givenOK = (new_given == given)
+ givenOK = ASF::Person.names_equivalent?(new_given, given)
badGiven += 1 unless givenOK
snOK = (new_sn == p.sn)