コード例 #1
0
    def test_1(self):
        data = self.get_data()

        for word, forms in data.items():
            taandyk = Taandyk(KyrgyzWord(word))
            for i in range(len(attrs_list)):
                attrs = attrs_list[i]
                self.assertEqual(
                    taandyk.make(attrs.jak, attrs.jeke, attrs.sylyk).word,
                    forms[i])
コード例 #2
0
    def test_chygysh_after_taandyk(self):
        data = self.get_data()
        for word, expected_forms in data.items():
            koptuk = San(KyrgyzWord(word)).koptuk()
            for i in range(len(attrs_list)):
                attr = attrs_list[i]
                jeke_form_expected = expected_forms[0][i]
                taandyk = Taandyk(KyrgyzWord(word)).make(attr.jak, attr.jeke, attr.sylyk)
                jondomo = Jondomo(taandyk)
                self.assertEqual(unicode(jondomo.chygysh()), jeke_form_expected)

                koptuk_form_expected = expected_forms[1][i]
                taandyk_koptuk = Taandyk(koptuk).make(attr.jak, attr.jeke, attr.sylyk)
                jondomo_koptuk = Jondomo(taandyk_koptuk)
                self.assertEqual(unicode(jondomo_koptuk.chygysh()), koptuk_form_expected)
コード例 #3
0
ファイル: affixing.py プロジェクト: MasterAlish/kyrgyz_tili
def apply_affix(affix_name, word_object):
    """
    Применяет аффикс по имени для указанного слова, подбирая соответсвующий класс Аффиксов
    :type word_object: kg_lang.kyrgyz.lang.KyrgyzWord
    """

    if affix_name == 'jondomo':
        jondomos = {'word_jondomo': Jondomo(word_object)}
        if word_object.last_affix() != "taandyk":
            jondomos['word_koptuk_jondomo'] = Jondomo(
                San(word_object).koptuk())
        return jondomos

    if affix_name == 'taandyk':
        return {
            'word_taandyk': Taandyk(word_object),
            'word_koptuk_taandyk': Taandyk(San(word_object).koptuk())
        }

    if affix_name == 'chak':
        return {
            'otkon_chak': OtkonChak(word_object),
            'uchur_chak': UchurChak(word_object),
            'keler_chak': KelerChak(word_object)
        }

    if affix_name == 'kyimyl_atooch':
        return {
            'kyimyl_atooch_jondomo': Jondomo(KyimylAtooch(word_object).make())
        }

    muchos = {
        'salyshtyrma': SalyshtyrmaSynAtooch,
        'dai': DaiZatMuchosu,
        'gan': GanEtishMuchosu,
        'syz': SyzZatMuchosu,
        'luu': LuuZatMuchosu,
        'by': ByZatMuchosu,
        'dagy': DagyZatMuchosu,
        'ba': BaEtishMuchosu,
        'bash': BashEtishMuchosu,
        'chu': ChuEtishMuchosu,
        'chuday': ChudayEtishMuchosu,
    }

    if isinstance(affix_name, str) and affix_name in muchos:
        mucho_class = muchos[affix_name]
        return {affix_name: mucho_class(word_object)}

    if isinstance(affix_name, dict):
        result_affixes = {}
        for first_step_affix, next_steps in affix_name.items():
            affixes = apply_affix(first_step_affix, word_object).values()
            first_step_words = []
            for affix_name in affixes:
                if affix_name.is_pluralable():
                    first_step_words.append(affix_name.make(*men.as_args()))
                    first_step_words.append(affix_name.make(*sen.as_args()))
                    first_step_words.append(affix_name.make(*al.as_args()))
                    first_step_words.append(affix_name.make(*biz.as_args()))
                    first_step_words.append(affix_name.make(*siler.as_args()))
                    first_step_words.append(affix_name.make(*alar.as_args()))
                    first_step_words.append(affix_name.make(*siz.as_args()))
                    first_step_words.append(affix_name.make(*sizder.as_args()))
                else:
                    for transformer in affix_name.transformers():
                        if callable(transformer):
                            first_step_words.append(transformer(affix_name))
            for i in range(len(first_step_words)):
                new_word = first_step_words[i]
                for second_step_affix in next_steps:
                    for key, affix_inner in apply_affix(
                            second_step_affix, new_word).items():
                        result_affixes['%s_%d_%s' % (first_step_affix, i,
                                                     key)] = affix_inner
        return result_affixes
    return {}