From 8cf85ca5efaf7b679e13e648729dfaf3b16dcdc8 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 24 Jul 2025 12:56:27 +0200 Subject: [PATCH] aliases twiddle --- parsers/caves.py | 2 +- parsers/people.py | 34 ++++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/parsers/caves.py b/parsers/caves.py index 90b9a93..2e39906 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -664,7 +664,7 @@ def read_cave(filename, mvf=None, cave=None): letter = "a" message = f"- Warning - Empty 'letter' field for '{eslug}' in multiple-entrance cave '{cave}', setting to {letter}." #eurl = f"{cave.url}_cave_edit/" - eurl = Path(cave.url).parent + f"{cave.slug()}_cave_edit/" + eurl = Path(cave.url).parent / f"{cave.slug()}_cave_edit/" # edit recognizer: (?P.*)/(?P[^/]+)_cave_edit/$ DataIssue.objects.create(parser="entrances", message=message, url=eurl) print(message) diff --git a/parsers/people.py b/parsers/people.py index eab1917..a290994 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -338,23 +338,31 @@ def GetPersonExpeditionNameLookup(expedition): == "Mike Rickardson". """ global Gpersonexpeditionnamelookup + + def apply_initials(variations, a, l): + variations.append(a + l) + variations.append(a + " " + l) + variations.append(a + " " + l[0]) + variations.append(a + l[0]) + variations.append(a + " " + l[0] + ".") + variations.append(a[0] + " " + l) + variations.append(a[0] + ". " + l) + variations.append(a[0] + l) + variations.append(a[0] + l[0]) # initials e.g. gb or bl + return variations - def apply_variations(f, l): + def apply_variations(f, l, n=""): """Be generous in guessing possible matches. Any duplicates will be ruled as invalid.""" f = f.lower() l = l.lower() variations = [] variations.append(f) variations.append(l) - variations.append(f + l) - variations.append(f + " " + l) - variations.append(f + " " + l[0]) - variations.append(f + l[0]) - variations.append(f + " " + l[0] + ".") - variations.append(f[0] + " " + l) - variations.append(f[0] + ". " + l) - variations.append(f[0] + l) - variations.append(f[0] + l[0]) # initials e.g. gb or bl + variations = apply_initials(variations, f, l) + if n: + variations.append(n) + variations = apply_initials(variations, n, f) + variations = apply_initials(variations, n, l) return variations res = Gpersonexpeditionnamelookup.get(expedition.name) @@ -381,11 +389,9 @@ def GetPersonExpeditionNameLookup(expedition): possnames.append(n) if l: - possnames += apply_variations(f, l) - - if n: - possnames += apply_variations(n, l) + possnames += apply_variations(f, l, n) + if f == "Adeleide".lower(): possnames += apply_variations("Adelaide", l) if f == "Adelaide".lower():