diff --git a/commemorations/tests.py b/commemorations/tests.py index 4b83ecb..0ce302e 100644 --- a/commemorations/tests.py +++ b/commemorations/tests.py @@ -14,6 +14,7 @@ def test_known_variant_pairs_match(self): ('Symeon', 'Simeon'), ('Cosmas', 'Kosmas'), ('Isaac', 'Isaak'), + ('Maximovich', 'Maximovitch'), ] for latin, greek in pairs: self.assertEqual(normalize_transliteration(latin), normalize_transliteration(greek)) @@ -37,6 +38,17 @@ def test_greek_spelling_finds_latin_spelled_saint(self): names = [saint.display_name for saint in response.context['results']] self.assertIn('St Athanasius the Great, patriarch of Alexandria', names) + def test_vitch_spelling_finds_vich_spelled_saint(self): + # A single story-bearing match -- the other "Maximovitch" (Metr. of + # Tobolsk) has no story, so it's excluded and this redirects + # straight to the one remaining detail page. + response = self.client.get(reverse('saint-search'), {'q': 'John Maximovitch'}) + + self.assertRedirects(response, reverse( + 'saint-detail', + args=['st-john-maximovich-archbishop-of-shanghai-and-san-francisco-1966-june-19-oc-7-2'], + )) + def test_single_result_redirects_to_detail_page(self): response = self.client.get(reverse('saint-search'), {'q': 'myra Nicholas'}) diff --git a/commemorations/transliteration.py b/commemorations/transliteration.py index bda6496..e22e12a 100644 --- a/commemorations/transliteration.py +++ b/commemorations/transliteration.py @@ -4,15 +4,18 @@ def normalize_transliteration(text): """Canonicalize common Greek/Latin transliteration spelling variants (e.g. "Athanasios" vs "Athanasius", "Dionysios" vs "Dionysius", "Cosmas" - vs "Kosmas") to the same form, so name search can match across them. - Not a general phonetic algorithm -- just the specific substitution - patterns found in this corpus, where names harvested from Greek-tradition - sources and names carried over from the older Slavic/abbamoses corpus - ended up using different transliteration conventions for the same - underlying name.""" + vs "Kosmas") and Slavic surname transliteration variants (e.g. + "Maximovitch" vs "Maximovich" -- older English convention rendered the + "-ovich" patronymic ending as "-ovitch") to the same form, so name + search can match across them. Not a general phonetic algorithm -- just + the specific substitution patterns found in this corpus, where names + harvested from Greek-tradition sources and names carried over from the + older Slavic/abbamoses corpus ended up using different transliteration + conventions for the same underlying name.""" text = text.lower() text = re.sub(r'c(?!h)', 'k', text) text = re.sub(r'y', 'i', text) text = re.sub(r'os\b', 'us', text) + text = re.sub(r'vitch\b', 'vich', text) return text