slightly more flexible detection of alphabetic numbering suffixes

This commit is contained in:
xenofem 2024-03-11 12:19:56 -04:00
parent 6b3982ecf0
commit 7726af7dab

View file

@ -606,10 +606,12 @@ def unique_hierarchical_prefix_numbering(entries, start_point=0):
def alphabetic_numbering(entries, start_point): def alphabetic_numbering(entries, start_point):
alphabetized = {} alphabetized = {}
for entry in entries: for entry in entries:
ending = nfc(entry.stem)[start_point:] ending = nfc(entry.stem)[start_point:].strip(' -_()')
if len(ending) > 1: if len(ending) > 1:
return None return None
index = 0 if ending == '' else ord(ending.lower()) - ord('a') + 1 index = 0 if ending == '' else ord(ending.lower()) - ord('a') + 1
if index < 0 or index > 26:
return None
if (index,) in alphabetized: if (index,) in alphabetized:
return None return None
alphabetized[(index,)] = [entry] alphabetized[(index,)] = [entry]