def __init__(self, constants=ScansionConstants(), syllabifier=Syllabifier(), optional_transform: bool = False, *args, **kwargs): super().__init__(*args, **kwargs) self.constants = constants self.remove_punct_map = StringUtils.remove_punctuation_dict() self.punctuation_substitutions = StringUtils.punctuation_for_spaces_dict( ) self.metrical_validator = MetricalValidator(constants) self.formatter = ScansionFormatter(constants) self.syllabifier = syllabifier self.optional_transform = optional_transform self.inverted_amphibrach_re = re.compile(r"{}\s*{}\s*{}".format( self.constants.STRESSED, self.constants.UNSTRESSED, self.constants.STRESSED)) self.syllable_matcher = re.compile( r"[{}]".format(self.constants.VOWELS + self.constants.ACCENTED_VOWELS + self.constants.LIQUIDS + self.constants.MUTES)) self.SPONDAIC_PENTAMETER = self.constants.SPONDEE + self.constants.SPONDEE + \ self.constants.STRESSED + self.constants.DACTYL + \ self.constants.DACTYL + self.constants.OPTIONAL_ENDING self.DACTYLIC_PENTAMETER = self.constants.DACTYL + self.constants.DACTYL + \ self.constants.STRESSED + self.constants.DACTYL + \ self.constants.DACTYL + self.constants.OPTIONAL_ENDING
def __init__(self, constants=None, syllabifier=None, optional_transform: bool = False, *args, **kwargs)->None: """ :param constants: None or a class that implements ScansionConstants :param syllabifier: None or a class that implements Syllabifier methods :param optional_tranform: boolean, whether or not to apply aggresive verse transformations. :param kwargs: """ super().__init__(*args, **kwargs) self.constants = ScansionConstants() if constants is None else constants self.syllabifier = Syllabifier() if syllabifier is None else syllabifier self.remove_punct_map = string_utils.remove_punctuation_dict() self.punctuation_substitutions = string_utils.punctuation_for_spaces_dict() self.metrical_validator = MetricalValidator(self.constants) self.formatter = ScansionFormatter(self.constants) self.optional_transform = optional_transform self.inverted_amphibrach_re = re.compile( r"{}\s*{}\s*{}".format(self.constants.STRESSED, self.constants.UNSTRESSED, self.constants.STRESSED)) self.syllable_matcher = re.compile(r"[{}]".format(self.constants.VOWELS + self.constants.ACCENTED_VOWELS + self.constants.LIQUIDS + self.constants.MUTES)) self.SPONDAIC_PENTAMETER = self.constants.SPONDEE + self.constants.SPONDEE + \ self.constants.STRESSED + self.constants.DACTYL + \ self.constants.DACTYL + self.constants.OPTIONAL_ENDING self.DACTYLIC_PENTAMETER = self.constants.DACTYL + self.constants.DACTYL + \ self.constants.STRESSED + self.constants.DACTYL + \ self.constants.DACTYL + self.constants.OPTIONAL_ENDING
def __init__(self, constants=ScansionConstants()): self.constants = constants self.stress_accent_dict = dict( zip( list(self.constants.VOWELS + self.constants.ACCENTED_VOWELS), list(self.constants.ACCENTED_VOWELS + self.constants.ACCENTED_VOWELS)))
def __init__(self, constants=ScansionConstants()): self.constants = constants self.VALID_HEXAMETERS = [ self._build_hexameter_template(bin(x)[3:]) for x in range(32, 64) ] self.VALID_HENDECASYLLABLES = self._build_hendecasyllable_templates() self.VALID_PENTAMETERS = self._build_pentameter_templates()
def demacronize(string_matrix: List[List[str]]) -> List[List[str]]: """ Transform macronized vowels into normal vowels :param string_matrix: a data matrix: a list wrapping a list of strings, with each sublist being a sentence. :return: string_matrix >>> demacronize([['ōdī', 'et', 'amō',]]) [['odi', 'et', 'amo']] """ scansion = ScansionConstants() accent_dropper = str.maketrans(scansion.ACCENTED_VOWELS, scansion.VOWELS) return [[word.translate(accent_dropper) for word in sentence] for sentence in string_matrix]
def __init__(self, constants=ScansionConstants()): self.constants = constants self.consonant_matcher = re.compile("[{}]".format(constants.CONSONANTS)) self.vowel_matcher = re.compile( "[{}]".format(constants.VOWELS + constants.ACCENTED_VOWELS)) self.consonantal_i_matcher = re.compile( r"\b[iIīĪ][{}]".format(constants.VOWELS + constants.ACCENTED_VOWELS)) self.remove_punct_map = string_utils.remove_punctuation_dict() self.kw_matcher = re.compile("[kK][w]") self.ACCEPTABLE_CHARS = constants.ACCENTED_VOWELS + constants.VOWELS + ' ' \ + constants.CONSONANTS self.diphthongs = [d for d in constants.DIPTHONGS if d not in ["ui", "Ui", "uī"]]
def __init__(self, constants=ScansionConstants(), syllabifier=Syllabifier(), **kwargs): self.constants = constants self.remove_punct_map = string_utils.remove_punctuation_dict() self.punctuation_substitutions = string_utils.punctuation_for_spaces_dict( ) self.metrical_validator = MetricalValidator(constants) self.formatter = ScansionFormatter(constants) self.syllabifier = syllabifier self.inverted_amphibrach_re = re.compile(r"{}\s*{}\s*{}".format( self.constants.STRESSED, self.constants.UNSTRESSED, self.constants.STRESSED)) self.syllable_matcher = re.compile( r"[{}]".format(self.constants.VOWELS + self.constants.ACCENTED_VOWELS + self.constants.LIQUIDS + self.constants.MUTES))
def __init__(self, constants=None, syllabifier=None, **kwargs): """ :param constants: None or a class that implements ScansionConstants :param syllabifier: None or a class that implements Syllabifier methods :param kwargs: """ self.constants = ScansionConstants( ) if constants is None else constants self.syllabifier = Syllabifier( ) if syllabifier is None else syllabifier self.remove_punct_map = string_utils.remove_punctuation_dict() self.punctuation_substitutions = string_utils.punctuation_for_spaces_dict( ) self.metrical_validator = MetricalValidator(self.constants) self.formatter = ScansionFormatter(self.constants) self.inverted_amphibrach_re = re.compile(r"{}\s*{}\s*{}".format( self.constants.STRESSED, self.constants.UNSTRESSED, self.constants.STRESSED)) self.syllable_matcher = re.compile( r"[{}]".format(self.constants.VOWELS + self.constants.ACCENTED_VOWELS + self.constants.LIQUIDS + self.constants.MUTES))
def __init__(self): self.alternate_font_greek_to_roman = dict([ ("I", "i"), ("Α", "A"), ("Αι", "Ae"), ("Β", "B"), ("Γ", "G"), ("Δ", "D"), ("Ε", "E"), ("Ει", "E"), ("Ζ", "Z"), ("Η", "Ē"), ("Θ", "Th"), ("Ι", "I"), ("Κ", "K"), ("Λ", "L"), ("Μ", "M"), ("Ν", "N"), ("Ξ", "X"), ("Ο", "O"), ("Οι", "Oe"), ("Ου", "Ou"), ("Π", "P"), ("Ρ", "R"), ("Σ", "S"), ("Τ", "T"), ("Υ", "Y"), ("Υι", "Ui"), ("Φ", "Ph"), ("Χ", "Kh"), ("Ψ", "Ps"), ("Ω", "Ō"), ("α", "a"), ("αι", "ae"), ("β", "b"), ("γ", "g"), ("γγ", "ng"), ("γκ", "nc"), ("γξ", "nx"), ("γχ", "nch"), ("δ", "d"), ("ε", "e"), ("ει", "ei"), ("ζ", "z"), ("η", "ē"), ("θ", "th"), ("ι", "i"), ("κ", "k"), ("λ", "l"), ("μ", "m"), ("ν", "n"), ("ξ", "x"), ("ο", "o"), ("οι", "oe"), ("ου", "ou"), ("π", "p"), ("ρ", "r"), ("ς", "s"), ("σ", "s"), ("τ", "t"), ("υ", "u"), ("υι", "ui"), ("φ", "ph"), ("χ", "kh"), ("ψ", "ps"), ("ω", "ō"), ]) # type: Dict[str, str] self.greek_to_roman = dict([ ("W", "V"), ("j", "i"), ("w", "v"), ("¯", " "), ("Ō", "O"), ("ʼ", " "), ("ʽ", " "), ("˘", " "), ("̀", " "), ("́", " "), ("̄", " "), ("̈", " "), ("̓", " "), ("̔", " "), ("͂", " "), ("ͅ", " "), ("ʹ", " "), ("Ά", "A"), ("ΐ", "i"), ("ά", "a"), ("έ", "e"), ("ή", "ē"), ("ί", "i"), ("ΰ", "u"), ("ϊ", "i"), ("ϋ", "u"), ("ό", "o"), ("ύ", "u"), ("ώ", "ō"), ("ϛ", "s"), ("ϝ", " "), ("ϟ", " "), ("ϡ", " "), ("ἀ", "a"), ("ἁ", "ha"), ("ἂ", "a"), ("ἃ", "ha"), ("ἄ", "a"), ("ἅ", "ha"), ("ἆ", "a"), ("ἇ", "ha"), ("Ἀ", "A"), ("Ἁ", "Ha"), ("Ἂ", "Ha"), ("Ἃ", "Ha "), ("Ἄ", "A"), ("Ἅ", "Ha"), ("Ἆ", "A"), ("ἐ", "e"), ("ἑ", "he"), ("ἒ", "e"), ("ἓ", "he"), ("ἔ", "e"), ("ἕ", "he"), ("Ἐ", "E"), ("Ἑ", "He"), ("Ἓ", "He"), ("Ἔ", "E"), ("Ἕ", "E"), ("ἠ", "ē"), ("ἡ", "hē"), ("ἢ", "ē"), ("ἣ", "hē"), ("ἤ", "ē"), ("ἥ", "hē"), ("ἦ", "ē"), ("ἧ", "hē"), ("Ἠ", "Ē"), ("Ἡ", "Hē"), ("Ἢ", "Hē"), ("Ἤ", "Ē"), ("Ἥ", "Ē"), ("Ἦ", "Ē"), ("Ἧ", "Hē"), ("ἰ", "i"), ("ἱ", "hi"), ("ἲ", "i"), ("ἳ", "hi"), ("ἴ", "i"), ("ἵ", "hi"), ("ἶ", "i"), ("ἷ", "hi"), ("Ἰ", "I"), ("Ἱ", "Hi"), ("Ἴ", "I"), ("Ἵ", "I"), ("Ἶ", "I"), ("ὀ", "o"), ("ὁ", "ho"), ("ὂ", "o"), ("ὃ", "ho"), ("ὄ", "o"), ("ὅ", "ho"), ("Ὀ", "O"), ("Ὁ", "Ho"), ("Ὃ", "Ho"), ("Ὄ", "O"), ("Ὅ", "Ho"), ("ὐ", "u"), ("ὑ", "hu"), ("ὒ", "u"), ("ὓ", "hu"), ("ὔ", "u"), ("ὕ", "hu"), ("ὖ", "u"), ("ὗ", "hu"), ("Ὑ", "Hy"), ("Ὕ", "Y"), ("Ὗ", "Hu"), ("ὠ", "ō"), ("ὡ", "hō"), ("ὢ", "ō"), ("ὣ", "ho"), ("ὤ", "ō"), ("ὥ", "hō"), ("ὦ", "ō"), ("ὧ", "hō"), ("Ὠ", "O"), ("Ὡ", "Hō"), ("Ὣ", "Hō"), ("Ὤ", "O"), ("Ὥ", "Ō"), ("Ὦ", "O"), ("Ὧ", "Hō"), ("ὰ", "a"), ("ά", "a"), ("ὲ", "e"), ("έ", "e"), ("ὴ", "ē"), ("ή", "e"), ("ὶ", "i"), ("ί", "i"), ("ὸ", "o"), ("ό", "o"), ("ὺ", "u"), ("ύ", "u"), ("ὼ", "ō"), ("ώ", "ō"), ("ᾀ", "a"), ("ᾁ", "ha"), ("ᾄ", "a"), ("ᾅ", "ha"), ("ᾆ", "a"), ("ᾇ", "ha"), ("ᾐ", "ē"), ("ᾑ", "hē"), ("ᾔ", "ē"), ("ᾕ", "hē"), ("ᾖ", "ē"), ("ᾗ", "hē"), ("ᾘ", "Ē"), ("ᾠ", "ō"), ("ᾡ", "Hō"), ("ᾤ", "ō"), ("ᾦ", "ō"), ("ᾧ", "hō"), ("ᾬ", "Ō"), ("ᾲ", "a"), ("ᾳ", "a"), ("ᾴ", "a"), ("ᾶ", "a"), ("ᾷ", "a"), ("᾿", " "), ("ῂ", "ē"), ("ῃ", "ē"), ("ῄ", "ē"), ("ῆ", "ē"), ("ῇ", "ē"), ("ῒ", "i"), ("ΐ", "i"), ("ῖ", "i"), ("ῗ", "i"), ("ῢ", "u"), ("ῤ", "r"), ("ῥ", "rh"), ("ῦ", "u"), ("Ῥ", "Rh"), ("ῲ", "ō"), ("ῳ", "ō"), ("ῴ", "ō"), ("ῶ", "ō"), ("ῷ", "ō"), ]) # type: Dict[str, str] self.greek_to_roman_dipthongs = dict([ (" Ἥ", "Hē"), ("Αὖ", "Au"), ("Αἱ", "Hai"), ("Αὑ", "Hau"), ("Αὕ", "Hau"), ("Αὗ", "Hau"), ("Γγ", "Ng"), ("Ει", "Ei"), ("Εὖ", "Eu"), ("Εἵ", "Hei"), ("Εἶ", "Ei"), ("Εἷ", "Hei"), ("Εὑ", "Heu"), ("Εὔ", "Eu"), ("Οι", "Oi"), ("Ου", "Ou"), ("Οἱ", "Hoi"), ("Οἳ", "Hoi"), ("Οἵ", "Hoi"), ("Οἷ", "Hoi"), ("Οὑ", "Hou"), ("Οὓ", "Hou"), ("Οὕ", "Hou"), ("Οὗ", "Hou"), ("Υἱ", "Hui"), ("αἱ", "hai"), ("αὑ", "hau"), ("αὕ", "hau"), ("αὖ", "au"), ("αὗ", "hau"), ("γγ", "ng"), ("ει", "ei"), ("εἵ", "hei"), ("εἶ", "ei"), ("εἷ", "hei"), ("εὑ", "heu"), ("εὔ", "eu"), ("εὖ", "eu"), ("οι", "oi"), ("ου", "ou"), ("οἱ", "hoi"), ("οἳ", "hoi"), ("οἵ", "hoi"), ("οἷ", "hoi"), ("οὑ", "hou"), ("οὓ", "hou"), ("οὕ", "hou"), ("οὗ", "hou"), ("υἱ", "hui"), ]) # type: Dict[str, str] scansion_constants = ScansionConstants() self.macrons_to_vowels = dict( zip( list(scansion_constants.ACCENTED_VOWELS), list(scansion_constants.VOWELS), )) # type: Dict[str, str]
def __init__(self): self.alternate_font_greek_to_roman = dict([('I', 'i'), ('Α', 'A'), ('Αι', 'Ae'), ('Β', 'B'), ('Γ', 'G'), ('Δ', 'D'), ('Ε', 'E'), ('Ει', 'E'), ('Ζ', 'Z'), ('Η', 'Ē'), ('Θ', 'Th'), ('Ι', 'I'), ('Κ', 'K'), ('Λ', 'L'), ('Μ', 'M'), ('Ν', 'N'), ('Ξ', 'X'), ('Ο', 'O'), ('Οι', 'Oe'), ('Ου', 'Ou'), ('Π', 'P'), ('Ρ', 'R'), ('Σ', 'S'), ('Τ', 'T'), ('Υ', 'Y'), ('Υι', 'Ui'), ('Φ', 'Ph'), ('Χ', 'Kh'), ('Ψ', 'Ps'), ('Ω', 'Ō'), ('α', 'a'), ('αι', 'ae'), ('β', 'b'), ('γ', 'g'), ('γγ', 'ng'), ('γκ', 'nc'), ('γξ', 'nx'), ('γχ', 'nch'), ('δ', 'd'), ('ε', 'e'), ('ει', 'ei'), ('ζ', 'z'), ('η', 'ē'), ('θ', 'th'), ('ι', 'i'), ('κ', 'k'), ('λ', 'l'), ('μ', 'm'), ('ν', 'n'), ('ξ', 'x'), ('ο', 'o'), ('οι', 'oe'), ('ου', 'ou'), ('π', 'p'), ('ρ', 'r'), ('ς', 's'), ('σ', 's'), ('τ', 't'), ('υ', 'u'), ('υι', 'ui'), ('φ', 'ph'), ('χ', 'kh'), ('ψ', 'ps'), ('ω', 'ō') ]) # type: Dict[str, str] self.greek_to_roman = dict([('W', 'V'), ('j', 'i'), ('w', 'v'), ('¯', ' '), ('Ō', 'O'), ('ʼ', ' '), ('ʽ', ' '), ('˘', ' '), ('̀', ' '), ('́', ' '), ('̄', ' '), ('̈', ' '), ('̓', ' '), ('̔', ' '), ('͂', ' '), ('ͅ', ' '), ('ʹ', ' '), ('Ά', 'A'), ('ΐ', 'i'), ('ά', 'a'), ('έ', 'e'), ('ή', 'ē'), ('ί', 'i'), ('ΰ', 'u'), ('ϊ', 'i'), ('ϋ', 'u'), ('ό', 'o'), ('ύ', 'u'), ('ώ', 'ō'), ('ϛ', 's'), ('ϝ', ' '), ('ϟ', ' '), ('ϡ', ' '), ('ἀ', 'a'), ('ἁ', 'ha'), ('ἂ', 'a'), ('ἃ', 'ha'), ('ἄ', 'a'), ('ἅ', 'ha'), ('ἆ', 'a'), ('ἇ', 'ha'), ('Ἀ', 'A'), ('Ἁ', 'Ha'), ('Ἂ', 'Ha'), ('Ἃ', 'Ha '), ('Ἄ', 'A'), ('Ἅ', 'Ha'), ('Ἆ', 'A'), ('ἐ', 'e'), ('ἑ', 'he'), ('ἒ', 'e'), ('ἓ', 'he'), ('ἔ', 'e'), ('ἕ', 'he'), ('Ἐ', 'E'), ('Ἑ', 'He'), ('Ἓ', 'He'), ('Ἔ', 'E'), ('Ἕ', 'E'), ('ἠ', 'ē'), ('ἡ', 'hē'), ('ἢ', 'ē'), ('ἣ', 'hē'), ('ἤ', 'ē'), ('ἥ', 'hē'), ('ἦ', 'ē'), ('ἧ', 'hē'), ('Ἠ', 'Ē'), ('Ἡ', 'Hē'), ('Ἢ', 'Hē'), ('Ἤ', 'Ē'), ('Ἥ', 'Ē'), ('Ἦ', 'Ē'), ('Ἧ', 'Hē'), ('ἰ', 'i'), ('ἱ', 'hi'), ('ἲ', 'i'), ('ἳ', 'hi'), ('ἴ', 'i'), ('ἵ', 'hi'), ('ἶ', 'i'), ('ἷ', 'hi'), ('Ἰ', 'I'), ('Ἱ', 'Hi'), ('Ἴ', 'I'), ('Ἵ', 'I'), ('Ἶ', 'I'), ('ὀ', 'o'), ('ὁ', 'ho'), ('ὂ', 'o'), ('ὃ', 'ho'), ('ὄ', 'o'), ('ὅ', 'ho'), ('Ὀ', 'O'), ('Ὁ', 'Ho'), ('Ὃ', 'Ho'), ('Ὄ', 'O'), ('Ὅ', 'Ho'), ('ὐ', 'u'), ('ὑ', 'hu'), ('ὒ', 'u'), ('ὓ', 'hu'), ('ὔ', 'u'), ('ὕ', 'hu'), ('ὖ', 'u'), ('ὗ', 'hu'), ('Ὑ', 'Hy'), ('Ὕ', 'Y'), ('Ὗ', 'Hu'), ('ὠ', 'ō'), ('ὡ', 'hō'), ('ὢ', 'ō'), ('ὣ', 'ho'), ('ὤ', 'ō'), ('ὥ', 'hō'), ('ὦ', 'ō'), ('ὧ', 'hō'), ('Ὠ', 'O'), ('Ὡ', 'Hō'), ('Ὣ', 'Hō'), ('Ὤ', 'O'), ('Ὥ', 'Ō'), ('Ὦ', 'O'), ('Ὧ', 'Hō'), ('ὰ', 'a'), ('ά', 'a'), ('ὲ', 'e'), ('έ', 'e'), ('ὴ', 'ē'), ('ή', 'e'), ('ὶ', 'i'), ('ί', 'i'), ('ὸ', 'o'), ('ό', 'o'), ('ὺ', 'u'), ('ύ', 'u'), ('ὼ', 'ō'), ('ώ', 'ō'), ('ᾀ', 'a'), ('ᾁ', 'ha'), ('ᾄ', 'a'), ('ᾅ', 'ha'), ('ᾆ', 'a'), ('ᾇ', 'ha'), ('ᾐ', 'ē'), ('ᾑ', 'hē'), ('ᾔ', 'ē'), ('ᾕ', 'hē'), ('ᾖ', 'ē'), ('ᾗ', 'hē'), ('ᾘ', 'Ē'), ('ᾠ', 'ō'), ('ᾡ', 'Hō'), ('ᾤ', 'ō'), ('ᾦ', 'ō'), ('ᾧ', 'hō'), ('ᾬ', 'Ō'), ('ᾲ', 'a'), ('ᾳ', 'a'), ('ᾴ', 'a'), ('ᾶ', 'a'), ('ᾷ', 'a'), ('᾿', ' '), ('ῂ', 'ē'), ('ῃ', 'ē'), ('ῄ', 'ē'), ('ῆ', 'ē'), ('ῇ', 'ē'), ('ῒ', 'i'), ('ΐ', 'i'), ('ῖ', 'i'), ('ῗ', 'i'), ('ῢ', 'u'), ('ῤ', 'r'), ('ῥ', 'rh'), ('ῦ', 'u'), ('Ῥ', 'Rh'), ('ῲ', 'ō'), ('ῳ', 'ō'), ('ῴ', 'ō'), ('ῶ', 'ō'), ('ῷ', 'ō')]) # type: Dict[str, str] self.greek_to_roman_dipthongs = dict([(' Ἥ', 'Hē'), ('Αὖ', 'Au'), ('Αἱ', 'Hai'), ('Αὑ', 'Hau'), ('Αὕ', 'Hau'), ('Αὗ', 'Hau'), ('Γγ', 'Ng'), ('Ει', 'Ei'), ('Εὖ', 'Eu'), ('Εἵ', 'Hei'), ('Εἶ', 'Ei'), ('Εἷ', 'Hei'), ('Εὑ', 'Heu'), ('Εὔ', 'Eu'), ('Οι', 'Oi'), ('Ου', 'Ou'), ('Οἱ', 'Hoi'), ('Οἳ', 'Hoi'), ('Οἵ', 'Hoi'), ('Οἷ', 'Hoi'), ('Οὑ', 'Hou'), ('Οὓ', 'Hou'), ('Οὕ', 'Hou'), ('Οὗ', 'Hou'), ('Υἱ', 'Hui'), ('αἱ', 'hai'), ('αὑ', 'hau'), ('αὕ', 'hau'), ('αὖ', 'au'), ('αὗ', 'hau'), ('γγ', 'ng'), ('ει', 'ei'), ('εἵ', 'hei'), ('εἶ', 'ei'), ('εἷ', 'hei'), ('εὑ', 'heu'), ('εὔ', 'eu'), ('εὖ', 'eu'), ('οι', 'oi'), ('ου', 'ou'), ('οἱ', 'hoi'), ('οἳ', 'hoi'), ('οἵ', 'hoi'), ('οἷ', 'hoi'), ('οὑ', 'hou'), ('οὓ', 'hou'), ('οὕ', 'hou'), ('οὗ', 'hou'), ('υἱ', 'hui') ]) # type: Dict[str, str] scansion_constants = ScansionConstants() self.macrons_to_vowels = dict( zip(list(scansion_constants.ACCENTED_VOWELS), list(scansion_constants.VOWELS))) # type: Dict[str, str]