From e9790e70d64c3e63336aac53eee0fcd22b30f407 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 8 Oct 2022 01:52:10 +0300 Subject: abbrv. names now accepted when parsing logbooks, survex --- parsers/people.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'parsers/people.py') diff --git a/parsers/people.py b/parsers/people.py index 6ae9c2b..cc061ef 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -146,6 +146,8 @@ def GetPersonExpeditionNameLookup(expedition): #print("Calculating GetPersonExpeditionNameLookup for " + expedition.year) personexpeditions = PersonExpedition.objects.filter(expedition=expedition) + short = {} + dellist = [] for personexpedition in personexpeditions: possnames = [ ] f = unidecode(unescape(personexpedition.person.first_name.lower())) @@ -158,6 +160,12 @@ def GetPersonExpeditionNameLookup(expedition): possnames.append(f[0] + " " + l) possnames.append(f[0] + l[0]) # initials e.g. gb or bl possnames.append(f) + + lim = min(4, len(f)+1) # short form, e.g. Dan for Daniel. May be duplicate, e.g. several Dave + if f[:lim] not in short: + short[f[:lim]]= personexpedition + else: + dellist.append(f[:lim]) if full not in possnames: possnames.append(full) if personexpedition.nickname not in possnames: @@ -180,6 +188,12 @@ def GetPersonExpeditionNameLookup(expedition): for possname in duplicates: del res[possname] + + for possname in dellist: + if possname in short: #always true ? + del short[possname] + for shortname in short: + res[shortname] = short[shortname] Gpersonexpeditionnamelookup[expedition.name] = res return res -- cgit v1.2.3