I knew that a necessary component of a comprehensive morphological analyzer for Ancient Greek was going to be a library for handling accentuation, so back in January 2014, I started the
greek-accentuation Python library.
It consists of three modules:
The characters module provides basic analysis and manipulation of Greek characters in terms of their Unicode diacritics as if decomposed. So you can use it to add, remove or test for breathing, accents, iota subscript or length diacritics.
>>> base('ᾳ') 'α' >>> iota_subscript('ᾳ') == IOTA_SUBSCRIPT True >>> add_diacritic('α', IOTA_SUBSCRIPT) 'ᾳ'
The syllabify module provides basic analysis and manipulation of Greek syllables. It can syllabify words, give you the onset, nucleus, code, rime or body of a syllable, judge syllable length or give you the accentuation class of word.
>>> syllabify('γυναικός') ['γυ', 'ναι', 'κός'] >>> penult('οἰκία') 'κί' >>> paroxytone('λόγος') True
The accentuation module uses the other two modules to accentuate Ancient Greek words. As well as listing
possible_accentuations for a given unaccented word, it can produce
recessive and (given another form with an accent)
The library is open source under an MIT license. You can get the package on PyPI and the source repo is https://github.com/jtauber/greek-accentuation.