Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions commemorations/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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'})

Expand Down
15 changes: 9 additions & 6 deletions commemorations/transliteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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