diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2022-10-08 01:52:10 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2022-10-08 01:52:10 +0300 |
commit | e9790e70d64c3e63336aac53eee0fcd22b30f407 (patch) | |
tree | 0cf2a93628af76c329daec918a25fb3ee03feccc /parsers/people.py | |
parent | 55bc042798b208c19c8e4ab3cef69a92e5df0fa9 (diff) | |
download | troggle-e9790e70d64c3e63336aac53eee0fcd22b30f407.tar.gz troggle-e9790e70d64c3e63336aac53eee0fcd22b30f407.tar.bz2 troggle-e9790e70d64c3e63336aac53eee0fcd22b30f407.zip |
abbrv. names now accepted when parsing logbooks, survex
Diffstat (limited to 'parsers/people.py')
-rw-r--r-- | parsers/people.py | 14 |
1 files changed, 14 insertions, 0 deletions
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 |