def test_stem_transition(): from zeyrek.attributes import calculate_phonetic_attributes word_line = 'beyaz [P:Adj]' lexicon = RootLexicon.from_lines([word_line]) morphotactics = TurkishMorphotactics(lexicon=lexicon) dict_item = lexicon.get_matching_items('beyaz')[0] transition = morphotactics.stem_transitions.prefix_matches('beyaz')[0] assert transition.to_ == adjectiveRoot_ST assert str( transition) == "<(Dict: beyaz [P:Adj]):beyaz → [adjectiveRoot_ST:Adj]>" assert transition.condition is None assert transition.condition_count == 0 assert transition.dict_item.lemma == 'beyaz' assert transition.from_ is root_S calculated_attrs = calculate_phonetic_attributes('beyaz') assert transition.attrs == calculated_attrs assert type(transition.to_) == MorphemeState
def lex_from_lines(): return RootLexicon.from_lines(["adak", "elma", "beyaz [P:Adj]", "meyve"])
"""Tests for `zeyrek.conditions` module.""" import pytest from zeyrek.attributes import RootAttribute, PhoneticAttribute, \ calculate_phonetic_attributes from zeyrek.conditions import CombinedCondition, has, HasRootAttribute, DictionaryItemIs, not_have, \ HasPhoneticAttribute, DictionaryItemIsAny, NoSurfaceAfterDerivation, HasAnySuffixSurface, HasTail, \ PreviousMorphemeIs, PreviousStateIs, LastDerivationIs, HasDerivation, PreviousStateIsNot, HasTailSequence, \ ContainsMorphemeSequence, LastDerivationIsAny, PreviousGroupContains, CurrentGroupContainsAny, \ PreviousGroupContainsMorpheme, ContainsMorpheme, PreviousMorphemeIsAny, PreviousStateIsAny from zeyrek.lexicon import RootLexicon from zeyrek.morphology import MorphAnalyzer from zeyrek.morphotactics import SearchPath, StemTransition, noun_S, SurfaceTransition, SuffixTransition, \ adjectiveRoot_ST, verbRoot_S, become_S, vPast_S, past, verb, vCausTir_S, \ nom_ST, vAgt_S, a3sg_S, pnon_S, morphemes, agt, a3sg, noun, pnon, nom, vPass_S, vAble_S lex = RootLexicon.from_lines(["adak", "elma", "beyaz [P:Adj]", "meyve"]) @pytest.fixture(scope='session') def lex_from_lines(): return RootLexicon.from_lines(["adak", "elma", "beyaz [P:Adj]", "meyve"]) @pytest.fixture(scope='session') def mt_lexicon(): """Connects morphotactics graph and returns full lexicon""" lemmer = MorphAnalyzer() return lemmer.lexicon @pytest.fixture(scope='session')