def _decompose_suffix_blend(self, word, res=None): """Decomposing suffixes with replacements (typically due to the blending of identical sounds at the affix border). Example: >>> test_dict._decompose_suffix_e("historic") {'suffixes': ['-ic'], 'prefixes': [], 'roots': ['history'], 'other': [], 'original_word': []} Args: word (str): a potential nonce-word res (dict): if present, this dictionary will be updated Returns: (dict): updated or newly created dictionary with derivational data """ res = _check_res(res) for suffix in self.suffixes: if word.endswith(suffix) and len(word[:-len(suffix)]) > 2: for pair in self.replacements_in_suffixes: if suffix[0] == pair[1]: candidate = word.strip(suffix) + pair[0] if self.dictionary.is_a_word(candidate): res["suffixes"].append(dash_suffix(suffix)) res["roots"].append(candidate) return res
def _decompose_suffix_e(self, word, res=None): """Decomposing consonant suffixes before which final "e" was dropped. Example: >>> test_dict._decompose_suffix_e("imaginable") {'suffixes': ['-able'], 'prefixes': [], 'roots': ['imagine'], 'other': [], 'original_word': []} Args: word (str): a potential nonce-word res (dict): if present, this dictionary will be updated Returns: (dict): updated or newly created dictionary with derivational data """ res = _check_res(res) for suffix in self.suffixes: if word.endswith(suffix) and self.is_a_vowel(suffix[0]): candidate = word[:-len(suffix)] + "e" if self.dictionary.is_a_word(candidate): res["suffixes"].append(dash_suffix(suffix)) res["roots"].append(candidate) return res
def _decompose_suffix_doubling(self, word, res=None): """Decomposing vowel suffixes that led to doubling of the final consonant of the root. Example: >>> test_dict._decompose_suffix_doubling("kingdom") {'suffixes': ['-dom'], 'prefixes': [], 'roots': ['king'], 'other': [], 'original_word': []} Args: word (str): a potential nonce-word res (dict): if present, this dictionary will be updated Returns: (dict): updated or newly created dictionary with derivational data """ res = _check_res(res) for suffix in self.suffixes: if self.is_a_vowel(suffix[0]): if word.endswith(suffix) and len(word[:-len(suffix)]) > 2: if word[-(len(suffix) + 1)] == word[-(len(suffix) + 2)]: candidate = word[:-len(suffix) - 1] if self.dictionary.is_a_word(candidate): res["suffixes"].append(dash_suffix(suffix)) res["suffixes"].append(suffix) res["roots"].append(candidate) return res
def _decompose_suffix_simple(self, word, res=None): """The most basic decomposition of suffixes: no change to the stem. Example: >>> test_dict._decompose_suffix_simple("kingdom") {'suffixes': ['-dom'], 'prefixes': [], 'roots': ['king'], 'other': [], 'original_word': []} Args: word (str): a potential nonce-word res (dict): if present, this dictionary will be updated Returns: (dict): updated or newly created dictionary with derivational data """ res = _check_res(res) for suffix in self.suffixes: if word.endswith(suffix) and len(word[:-len(suffix)]) > 2: candidate = word[:-len(suffix)] if self.dictionary.is_a_word(candidate): res["suffixes"].append(dash_suffix(suffix)) res["roots"].append(candidate) return res
def _decompose_suffix_replacements(self, word, res=None): """Decomposing suffixes with phonetic changes before vocalic or consonantal suffixes. Example: >>> test_dict._decompose_suffix_replacements("happily") {'suffixes': ['-ly'], 'prefixes': [], 'roots': ['happy'], 'other': [], 'original_word': []} Args: word (str): a potential nonce-word res (dict): if present, this dictionary will be updated Returns: (dict): updated or newly created dictionary with derivational data """ res = _check_res(res) for suffix in self.suffixes: if word.endswith(suffix) and len(word[:-len(suffix)]) > 2: if self.is_a_vowel(suffix[0]): replacements = self.replacements_before_vowels else: replacements = self.replacements_before_consonants for pair in replacements: if word.endswith(pair[1] + suffix): candidate = rreplace(word.strip(suffix), pair[1], pair[0]) if self.dictionary.is_a_word(candidate): res["suffixes"].append(dash_suffix(suffix)) res["roots"].append(candidate) # else: return res
def _decompose_by_suffix_family(self, word, res=None): """Simple suffix replacements in the complex > simple direction Args: word (str): a potential nonce-word res (dict): if present, this dictionary will be updated Returns: (dict): updated or newly created dictionary with derivational data """ res = _check_res(res) for key, value in self.suffix_families.items(): key_suffix = key suffixes = value for suffix in suffixes: if word.endswith(suffix) and len(word[:-len(suffix)]) > 2: candidate = word[:-len(suffix)] + key_suffix if self.dictionary.is_a_word(candidate): res["suffixes"].append(dash_suffix(suffix)) res["roots"].append(candidate) return res
def _decompose_suffix_insertions(self, word, res=None): """Decomposing suffixes with insertions before vocalic or consonantal suffixes. Example: >>> test_dict._decompose_suffix_e("imaginable") {'suffixes': ['-able'], 'prefixes': [], 'roots': ['imagine'], 'other': [], 'original_word': []} Args: word (str): a potential nonce-word res (dict): if present, this dictionary will be updated Returns: (dict): updated or newly created dictionary with derivational data """ res = _check_res(res) for suffix in self.suffixes: if word.endswith(suffix) and len(word[:-len(suffix)]) > 2: if self.is_a_vowel(suffix[0]): insertions = self.insertions_before_vowels else: insertions = self.insertions_before_consonants for insert in insertions: candidate = word[:-len(suffix)] + insert if self.dictionary.is_a_word(candidate): res["suffixes"].append(dash_suffix(suffix)) res["roots"].append(candidate) return res