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 diff --git a/parsers/survex.py b/parsers/survex.py index 1782994..cbd7704 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -126,7 +126,7 @@ class LoadingSurvex(): rx_teammem = re.compile(r"(?i)"+instruments+"?(?:es|s)?\s+(.*)$") rx_teamold = re.compile(r"(?i)(.*)\s+"+instruments+"?(?:es|s)?$") rx_teamabs = re.compile(r"(?i)^\s*("+instruments+")?(?:es|s)?\s*$") - rx_person = re.compile(r"(?i) and | / |, | & | \+ |^both$|^none$") + rx_person = re.compile(r"(?i) and |/| / |, | & | \+ |^both$|^none$") rx_qm = re.compile(r'(?i)^\s*QM(\d+)\s+?([a-dA-DxX])\s+([\w\-\_]+)\.([\w\.\-]+)\s+(([\w\-]+)\.([\w\.\-]+)|\-)\s+(.+)$') # does not recognise non numeric suffix survey point ids rx_qm0 = re.compile(r'(?i)^\s*QM(\d+)\s+(.+)$') @@ -374,11 +374,11 @@ class LoadingSurvex(): # print(self.insp+message) # DataIssue.objects.create(parser='survex', message=message) pr.personexpedition = pe - pr.person = p.personexpedition.person + pr.person = pr.personexpedition.person pr.save() self.currentpersonexped.append(pe) # used in push/pop block code else: - message = "! *team {} '{}' FAIL personexpedition lookup on *date {} ({}) '{}'".format(year, p, survexblock.survexfile.path, survexblock, p.personname) + message = "! *team {} '{}' FAIL personexpedition lookup on *date {} ({}) '{}'".format(year, pr, survexblock.survexfile.path, survexblock, pr.personname) print(self.insp+message) DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))