2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

*team parsing much improved. Copes with everything now.

This commit is contained in:
Philip Sargent 2022-10-10 15:40:21 +03:00
parent 52a035e4cf
commit ff8eaa241e
2 changed files with 41 additions and 4 deletions

View File

@ -134,14 +134,31 @@ def who_is_this(year,possibleid):
else: else:
return None return None
def known_foreigner(id):
'''If this someone from ARGE or a known Austrian? Name has to be exact, no soft matching
'''
friends = ["P. Jeutter", "K. Jäger", "S. Steinberger", "R. Seebacher",
"Dominik Jauch", "Fritz Mammel", "Marcus Scheuerman",
"Uli Schütz", "Wieland Scheuerle",
"Kai Schwekend", "Regina Kaiser", "Thilo Müller","Wieland Scheuerle",
"Florian Gruner", "Helmut Stopka-Ebeler", "Aiko", "Mark Morgan"]
if id in friends:
return True
else:
return False
# Refactor. The dict GetPersonExpeditionNameLookup(expo) indexes by name and has values of personexpedition # Refactor. The dict GetPersonExpeditionNameLookup(expo) indexes by name and has values of personexpedition
# This is convoluted, the whole personexpedition concept is unnecessary. # This is convoluted, the whole personexpedition concept is unnecessary?
Gpersonexpeditionnamelookup = { } Gpersonexpeditionnamelookup = { }
def GetPersonExpeditionNameLookup(expedition): def GetPersonExpeditionNameLookup(expedition):
global Gpersonexpeditionnamelookup global Gpersonexpeditionnamelookup
def apply_variations(f, l): def apply_variations(f, l):
'''Be generous in guessing possible matches. Any duplicates will be ruled as invalid.
'''
f = f.lower() f = f.lower()
l = l.lower() l = l.lower()
variations = [] variations = []
@ -151,8 +168,9 @@ def GetPersonExpeditionNameLookup(expedition):
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 + 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) variations.append(f[0] + l)
variations.append(f[0] + l[0]) # initials e.g. gb or bl variations.append(f[0] + l[0]) # initials e.g. gb or bl
return variations return variations
@ -188,25 +206,36 @@ def GetPersonExpeditionNameLookup(expedition):
if f == "Robert".lower(): if f == "Robert".lower():
possnames += apply_variations("Bob", l) possnames += apply_variations("Bob", l)
if f == "Rob".lower():
possnames += apply_variations("Robert", l)
if f == "Andrew".lower(): if f == "Andrew".lower():
possnames += apply_variations("Andy", l) possnames += apply_variations("Andy", l)
if f == "Andy".lower(): if f == "Andy".lower():
possnames += apply_variations("Andrew", l) possnames += apply_variations("Andrew", l)
if f == "Michael".lower(): if f == "Michael".lower():
possnames += apply_variations("Mike", l) possnames += apply_variations("Mike", l)
if f == "David".lower(): if f == "David".lower():
possnames += apply_variations("Dave", l) possnames += apply_variations("Dave", l)
if f == "Dave".lower(): if f == "Dave".lower():
possnames += apply_variations("David", l) possnames += apply_variations("David", l)
if f == "Peter".lower(): if f == "Peter".lower():
possnames += apply_variations("Pete", l) possnames += apply_variations("Pete", l)
if f == "Pete".lower(): if f == "Pete".lower():
possnames += apply_variations("Peter", l) possnames += apply_variations("Peter", l)
if f == "Olly".lower(): if f == "Olly".lower():
possnames += apply_variations("Oliver", l) possnames += apply_variations("Oliver", l)
if f == "Oliver".lower(): if f == "Oliver".lower():
possnames += apply_variations("Olly", l) possnames += apply_variations("Olly", l)
if f == "Ollie".lower():
possnames += apply_variations("Oliver", l)
if f == "Oliver".lower():
possnames += apply_variations("Ollie", l)
if f == "Becka".lower(): if f == "Becka".lower():
possnames += apply_variations("Rebecca", l) possnames += apply_variations("Rebecca", l)

View File

@ -14,7 +14,7 @@ from django.utils.timezone import make_aware
import troggle.settings as settings import troggle.settings as settings
from troggle.core.models.caves import Cave, Entrance, QM, LogbookEntry from troggle.core.models.caves import Cave, Entrance, QM, LogbookEntry
from troggle.core.utils import get_process_memory, chaosmonkey from troggle.core.utils import get_process_memory, chaosmonkey
from troggle.parsers.people import GetPersonExpeditionNameLookup from troggle.parsers.people import GetPersonExpeditionNameLookup, known_foreigner
from troggle.parsers.logbooks import GetCaveLookup from troggle.parsers.logbooks import GetCaveLookup
from troggle.core.models.troggle import DataIssue, Expedition from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.models.survex import SurvexPersonRole, Wallet, SurvexDirectory, SurvexFile, SurvexBlock, SurvexStation from troggle.core.models.survex import SurvexPersonRole, Wallet, SurvexDirectory, SurvexFile, SurvexBlock, SurvexStation
@ -225,7 +225,7 @@ class LoadingSurvex():
(NB PersonTrip is a logbook thing) (NB PersonTrip is a logbook thing)
""" """
def record_team_member(tm, survexblock): def record_team_member(tm, survexblock):
tm = tm.strip('\"\'') tm = tm.strip('\"\'').strip()
# Refactor. The dict GetPersonExpeditionNameLookup(expo) indexes by name and has values of personexpedition # Refactor. The dict GetPersonExpeditionNameLookup(expo) indexes by name and has values of personexpedition
# This is convoluted, the whole personexpedition concept is unnecessary. # This is convoluted, the whole personexpedition concept is unnecessary.
@ -251,6 +251,10 @@ class LoadingSurvex():
personrole.expeditionday = survexblock.expeditionday personrole.expeditionday = survexblock.expeditionday
self.currentpersonexped.append(personexpedition) # used in push/pop block code self.currentpersonexped.append(personexpedition) # used in push/pop block code
personrole.save() personrole.save()
elif known_foreigner(tm): # note, not using .lower()
message = "- *team {} '{}' known foreigner on *team {} ({}) in '{}'".format(expo.year, tm, survexblock.survexfile.path, survexblock, line)
print(self.insp+message)
# DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
else: else:
# we know the date and expo, but can't find the person # we know the date and expo, but can't find the person
message = "! *team {} '{}' FAIL personexpedition lookup on *team {} ({}) in '{}'".format(expo.year, tm, survexblock.survexfile.path, survexblock, line) message = "! *team {} '{}' FAIL personexpedition lookup on *team {} ({}) in '{}'".format(expo.year, tm, survexblock.survexfile.path, survexblock, line)
@ -377,6 +381,10 @@ class LoadingSurvex():
pr.person = pr.personexpedition.person pr.person = pr.personexpedition.person
pr.save() pr.save()
self.currentpersonexped.append(pe) # used in push/pop block code self.currentpersonexped.append(pe) # used in push/pop block code
elif known_foreigner(pr.personname): # note, not using .lower()
message = "- *team {} '{}' known foreigner on *date {} ({}) in '{}'".format(expo.year, pr.personname, survexblock.survexfile.path, survexblock, line)
print(self.insp+message)
# DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
else: else:
message = "! *team {} '{}' FAIL personexpedition lookup on *date {} ({}) '{}'".format(year, pr.personname, survexblock.survexfile.path, survexblock, pr.personname) message = "! *team {} '{}' FAIL personexpedition lookup on *date {} ({}) '{}'".format(year, pr.personname, survexblock.survexfile.path, survexblock, pr.personname)
print(self.insp+message) print(self.insp+message)