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(), syllabifier=Syllabifier(), optional_transform: bool = 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.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 drop_all_punctuation(string_matrix: List[List[str]]) -> List[List[str]]: """ :param string_matrix: a data matrix: a list wrapping a list of strings, with each sublist being a sentence. :return: >>> drop_all_punctuation ([["I'm","ok!","Oh","%&*()[]{}!? Fine!"]]) [['Im', 'ok', 'Oh', 'Fine']] """ punct_spaces = remove_punctuation_dict() return [[drop_punctuation(word, transformation_table=punct_spaces) 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=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))