modern_greek_accentuation package#
Submodules#
modern_greek_accentuation.accentuation module#
- modern_greek_accentuation.accentuation.convert_to_monotonic(sentence_or_word: str, one_syllable_rule: bool = True) str#
Converts text in polytonic system to monotonic.
- Parameters:
sentence_or_word – Greek text of whatever length.
one_syllable_rule – If set to True, accent is removed from all single syllable words with some basic exceptions (like interrogative pronouns in questions).
- Returns:
Text converted to monotonic accentuation system.
- modern_greek_accentuation.accentuation.has_multiple_accents(word: str) bool#
- Parameters:
word – a single word
- Returns:
if a word has more than one accent, return True, else False.
- modern_greek_accentuation.accentuation.is_accented(syllable: str) bool#
- Parameters:
syllable – A single syllable.
- Returns:
True if accented, otherwise false.
- modern_greek_accentuation.accentuation.put_accent(word: str, accent_name: Accents, true_syllabification=True) str#
This function allows you to put a given accent on a word
- Parameters:
word – a single word, which can be already accented
accent_name – ANTEPENULTIMATE, PENULTIMATE, ULTIMATE
true_syllabification – unaccented “i” after consonants is not treated as vowel if set to True (sinizisi).
- Returns:
if accent_name param given incorrect, return input word, else return a word with a prescribed accent.
- modern_greek_accentuation.accentuation.put_accent_on_a_vowel(vowel: str) str#
- Parameters:
vowel – a single vowel
- Returns:
a vowel with the acute, if there is diaeresis on vowel, diaeresis stays, and if there were polytonic accents, they are replaced with the acute accent.
- modern_greek_accentuation.accentuation.put_accent_on_syllable(syllable: str) str#
- Parameters:
syllable – A single syllable, already accented or not.
- Returns:
An accented with the acute accent syllable
- modern_greek_accentuation.accentuation.put_accent_on_the_antepenultimate(word: str, true_syllabification=True) str#
This functions put accent on the antepenultimate syllable in a given word
- Parameters:
word – A single word.
true_syllabification – unaccented “i” after consonants is not treated as vowel if set to True (sinizisi).
- Returns:
The word with an accent on the antepenultimate.
- modern_greek_accentuation.accentuation.put_accent_on_the_penultimate(word: str, true_syllabification=True) str#
This functions put accent on the penultimate syllable in a given word :param word: A single word. :param true_syllabification: unaccented “i” after consonants is not treated as vowel if set to True (sinizisi). :return: The word with an accent on the penultimate.
- modern_greek_accentuation.accentuation.put_accent_on_the_ultimate(word: str, accent_one_syllable=True, second_accent=False, true_syllabification=True) str | None#
This functions put accent on the ultimate syllable in a given word
- Parameters:
word – A single word.
accent_one_syllable – If set to True, accent is removed from all single syllable words with some basic exceptions (like interrogative pronouns in questions).
second_accent – If there is already accent on antepenultimate and this flag is set to True, second accent will be added to a single word.
true_syllabification – Unaccented “i” after consonants is not treated as vowel if set to True (sinizisi).
- Returns:
The word with an accent on the ultimate.
- modern_greek_accentuation.accentuation.remove_all_accents(text: str, dieresis=True) str#
Remove all accent marks and leave everythin else.
- modern_greek_accentuation.accentuation.remove_all_diacritics(text: str, dieresis=True) str#
Remove all diacritics.
- modern_greek_accentuation.accentuation.remove_all_diacritics_with_dier(text: str, dieresis=True) str#
Remove all diacritics but dieresis
- modern_greek_accentuation.accentuation.remove_diacritics(*diacritics: list[str], diaeresis: bool = True) func#
Factory function for customizing functions that remove accents.
Even though Modern Greek has officially monotonic writing, there can be still instances of polytonic texts, so all diacritics which are known from ancient language, can be included.
- Parameters:
diacritics – List of diacritics to be removed, these are the possiblities: PSILI, DASIA, OXIA, VARIA, PERISPOMENI, YPOGEGRAMMENI, DIAERESIS (import them from resource module).
diaeresis – If dieresis is set to True, it checks if dieresis is expected because of accent position and in such a case dieresis is added.
- Returns:
Function that will remove diacritics that were set as *args from a given string.
- modern_greek_accentuation.accentuation.remove_diaer(text: str, dieresis=True) str#
Remove only dieresis
- modern_greek_accentuation.accentuation.remove_non_accent_diacritics(text: str, dieresis=True) str#
Remove both breathing marks and iota subscriptum
- modern_greek_accentuation.accentuation.remove_non_accent_diacritics_without_dieresis(text: str, dieresis=False) str#
Remove both breathing marks and iota subscriptum but leaves dieresis
- modern_greek_accentuation.accentuation.remove_redundand_diaeresis(word: str) str#
- Parameters:
word – A single word
- Returns:
If dieresis is not needed because position of an accent makes it superfluous, a word without dieresis.
- modern_greek_accentuation.accentuation.where_is_accent(word: str, true_syllabification=True) Accents | None#
This function will tell you where is the accent.
- Parameters:
word – a single word
true_syllabification – unaccented “i” before vowels or after certain vowels is not treated as a vowel if set to True (sinizisi).
- Returns:
ANTEPENULTIMATE, PENULTIMATE, ULTIMATE, INCORRECT_ACCENT, and if there is no accent, None
modern_greek_accentuation.augmentify module#
- modern_greek_accentuation.augmentify.add_augment(not_augmented_form: str) set[str]#
This functions create quite often multiple “proposals” for an augmented form, since it is a semi regular process in Modern Greek.
- Parameters:
not_augmented_form – Past verb form without an augment or perfect participle that needs to be augmented/reduplicated. Works also for internal augment.
- Returns:
A set with zero or more guessed forms.
- modern_greek_accentuation.augmentify.add_augment_with_prefix(prefixes: dict, not_augmented_form: str, on_vowel: bool = False) list[str]#
Helper function to be used in the `add_augment` function
- Parameters:
prefixes – a dictionary with prefixes as keys and prefixes before augment as values.
not_augmented_form – A past form with only past ending, before augmentation.
on_vowel – If on_vowel is False (default) it expects the (stem) verb to begin with a consonant.
- Returns:
a list with guessed forms.
- modern_greek_accentuation.augmentify.deaugment_past_form(form: str, lemma: str) str#
- Parameters:
form – an augmented past form, not prefixed
lemma – lemma is needed to check if an unaugmented stem begins on e or a
- Returns:
deaugmented form if successful, else the given form, with removed accents
- modern_greek_accentuation.augmentify.deaugment_prefixed_form(stem: str) str#
- Parameters:
stem – a verb stem (without an ending) that is or is supposed to be internally augmented
- Returns:
a prefixed verb stem with augment removed only if it was accented
- modern_greek_accentuation.augmentify.deaugment_stem(stem: str, lemma: str) str | None#
A function can be useful if you want to conjugate in the past tense a Greek verb that has an augment
- Parameters:
stem – a non prefixed verb past stem (without endings) that is or is supposed to be augmented, so it must has two syllable (like έκαν from έκανα)
lemma – Present form, and so unaugmented, of a verb.
- Returns:
deaugmented (if augment wasn’t accented in the first place) verb stem without accent, if not able to create, return None
modern_greek_accentuation.resources module#
modern_greek_accentuation.syllabify module#
- modern_greek_accentuation.syllabify.count_syllables(word: str, true_syllabification: bool = True) int#
Tells you how many syllables are it a given word :param word: a single word :param true_syllabification: if you want to divide word treating ‘i’ always as vowel, give it a False value :return: a number of syllables
- modern_greek_accentuation.syllabify.has_vowel(word: str) bool#
- Parameters:
word – a word or a syllable or a single Greek char
- Returns:
True if there is vowel inside the word string, else False
- modern_greek_accentuation.syllabify.is_vowel(letter: str) bool#
- modern_greek_accentuation.syllabify.modern_greek_syllabify(word: str, true_syllabification: bool = True) List[str]#
There is a problem as to how treat ‘i’ before vowels, as it is inconsistent across Modern Greek (χρη-σι-μο-ποι-ώ, υ-γι-ής, κα-τα-πιώ, και-νού-ργιο, Γιε-ώ-ργι-ος κτλ.), which mainly comes from the injection of katarevousian words into demotic vocabulary. It’s impossible to know it without a list of all “logies lekseis”. For the sake of accentuation, you can use true_syllabification flag, which, if False, will divide words treating ‘i’ always as vowel. Still the result of this function should be most of the time correct
- Parameters:
word – A word in Greek chars, works best if the word is accented
true_syllabification – if you want to divide word treating ‘i’ always as vowel, give it a False value
- Returns:
Array with syllables
modern_greek_accentuation.transcription module#
- modern_greek_accentuation.transcription.capitalize_or_upper_transcription(word: str, transcription: str) str#
- modern_greek_accentuation.transcription.erasmian_transcription(word: str) str#
It’s basically simple_transcription but it renders rough breathing as ‘h’
- Parameters:
word – word written in greek
- Returns:
Erasmian transcription
- modern_greek_accentuation.transcription.has_rough_breathing(word: str) bool#
Utility function, it checks if a word has a rough breathing :param word: a single word :return: True if rough breathing detected, else False
- modern_greek_accentuation.transcription.modern_transcription(word: str) str#
It has nothing to do with phonetic transcription in international phonetic alphabet. It’s thought mainly for Polish readers as a simple way to get transcription of Modern Greek texts accessible to lay people. Also it can be used to detect homophones, as it renders all i, e, o as the same char.
- Parameters:
word – written in Greek chars
- Returns:
simple transcription in following Modern Greek pronunciation.
- modern_greek_accentuation.transcription.simple_transcription(word: str, h=None, modern: bool = False) str#
This is the simplest possible transcription mostly based on Erasmian pronunciation. Such a transcription can be used for identifying words written with orthographic errors or written with latin chars.
- Parameters:
modern –
word – word written with Greek chars.
h – you can define how to render ‘η’, default is ‘h’.
modern_tr – modern transcription method if True
- Returns:
transcription, returns capitalised or all upper or all lower depending on the input.