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 __init__( self, constants=ScansionConstants(), syllabifier=Syllabifier(), optional_tranform=False, *args, **kwargs ): super().__init__(*args, **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 ) ) self.optional_transform = optional_tranform
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.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ī"] ]