Search in sources :

Example 1 with Morpheme

use of zemberek.morphology._morphotactics.Morpheme in project zemberek-nlp by ahmetaa.

the class TurkishMorphotactics method connectVerbAfterNounAdjStates.

private void connectVerbAfterNounAdjStates() {
    // elma-..-ε-yım
    nVerb_S.addEmpty(nPresent_S);
    // elma-ydı, çorap-tı
    nVerb_S.add(nPast_S, "+y>dI");
    // elma-ymış
    nVerb_S.add(nNarr_S, "+ymIş");
    nVerb_S.add(nCond_S, "+ysA");
    nVerb_S.add(vWhile_S, "+yken");
    // word "değil" is special. It contains negative suffix implicitly. Also it behaves like
    // noun->Verb Zero morpheme derivation. because it cannot have most Verb suffixes.
    // So we connect it to a separate root state "nVerbDegil" instead of Verb
    DictionaryItem degilRoot = lexicon.getItemById("değil_Verb");
    nVerbDegil_S.addEmpty(nNeg_S, rootIs(degilRoot));
    // copy transitions from nVerb_S
    nNeg_S.copyOutgoingTransitionsFrom(nVerb_S);
    Condition noFamily = notHave(RootAttribute.FamilyMember);
    // for preventing elmamım, elmamdım
    // pP1sg_S, pDat_ST, pA1sg_S, pA1pl_S, pA3pl_S, pP2sg_S, pP1pl_S, pP3sg_S, pP1sg_S
    // TODO: below causes "beklemedeyiz" to fail.
    ContainsMorpheme verbDeriv = new ContainsMorpheme(inf1, inf2, inf3, pastPart, futPart);
    Condition allowA1sgTrans = noFamily.andNot(new Conditions.ContainsMorphemeSequence(p1sg, nom)).andNot(verbDeriv);
    Condition allowA2sgTrans = noFamily.andNot(new Conditions.ContainsMorphemeSequence(p2sg, nom)).andNot(verbDeriv);
    Condition allowA3plTrans = noFamily.andNot(new Conditions.PreviousGroupContains(a3pl_S)).andNot(new Conditions.ContainsMorphemeSequence(p3pl, nom)).andNot(verbDeriv);
    Condition allowA2plTrans = noFamily.andNot(new Conditions.ContainsMorphemeSequence(p2pl, nom)).andNot(verbDeriv);
    Condition allowA1plTrans = noFamily.andNot(new Conditions.ContainsMorphemeSequence(p1sg, nom)).andNot(new Conditions.ContainsMorphemeSequence(p1pl, nom)).andNot(verbDeriv);
    // elma-yım
    nPresent_S.add(nA1sg_ST, "+yIm", allowA1sgTrans);
    nPresent_S.add(nA2sg_ST, "sIn", allowA1sgTrans);
    // elma-ε-ε-dır to non terminal A3sg. We do not allow ending with A3sg from empty Present tense.
    nPresent_S.addEmpty(nA3sg_S);
    // we allow `değil` to end with terminal A3sg from Present tense.
    nPresent_S.addEmpty(nA3sg_ST, rootIs(degilRoot));
    // elma-lar, elma-da-lar as Verb.
    // TODO: consider disallowing this for "elmalar" case.
    nPresent_S.add(nA3pl_ST, "lAr", notHave(RootAttribute.CompoundP3sg).andNot(new Conditions.PreviousGroupContainsMorpheme(inf1)).and(allowA3plTrans));
    // elma-ydı-m. Do not allow "elmaya-yım" (Oflazer accepts this)
    nPast_S.add(nA1sg_ST, "m", allowA1sgTrans);
    nNarr_S.add(nA1sg_ST, "Im", allowA1sgTrans);
    nPast_S.add(nA2sg_ST, "n", allowA2sgTrans);
    nNarr_S.add(nA2sg_ST, "sIn", allowA2sgTrans);
    nPast_S.add(nA1pl_ST, "k", allowA1plTrans);
    nNarr_S.add(nA1pl_ST, "Iz", allowA1plTrans);
    nPresent_S.add(nA1pl_ST, "+yIz", allowA1plTrans);
    nPast_S.add(nA2pl_ST, "InIz", allowA1plTrans);
    nNarr_S.add(nA2pl_ST, "sInIz", allowA1plTrans);
    nPresent_S.add(nA2pl_ST, "sInIz", allowA1plTrans);
    // elma-ydı-lar.
    nPast_S.add(nA3pl_ST, "lAr", notHave(RootAttribute.CompoundP3sg).and(allowA3plTrans));
    // elma-ymış-lar.
    nNarr_S.add(nA3pl_ST, "lAr", notHave(RootAttribute.CompoundP3sg).and(allowA3plTrans));
    // elma-ydı-ε
    nPast_S.addEmpty(nA3sg_ST);
    // elma-ymış-ε
    nNarr_S.addEmpty(nA3sg_ST);
    // narr+cons is allowed but not past+cond
    nNarr_S.add(nCond_S, "sA");
    nCond_S.add(nA1sg_ST, "m", allowA1sgTrans);
    nCond_S.add(nA2sg_ST, "n", allowA2sgTrans);
    nCond_S.add(nA1pl_ST, "k", allowA1plTrans);
    nCond_S.add(nA2pl_ST, "nIz", allowA2plTrans);
    nCond_S.addEmpty(nA3sg_ST);
    nCond_S.add(nA3pl_ST, "lAr");
    // for not allowing "elma-ydı-m-dır"
    Condition rejectNoCopula = new CurrentGroupContainsAny(nPast_S, nCond_S, nCopBeforeA3pl_S).not();
    // elma-yım-dır
    nA1sg_ST.add(nCop_ST, "dIr", rejectNoCopula);
    nA1pl_ST.add(nCop_ST, "dIr", rejectNoCopula);
    nA3sg_S.add(nCop_ST, ">dIr", rejectNoCopula);
    nA3pl_ST.add(nCop_ST, "dIr", rejectNoCopula);
    // Copula can come before A3pl.
    nPresent_S.add(nCopBeforeA3pl_S, ">dIr");
    nCopBeforeA3pl_S.add(nA3pl_ST, "lAr");
}
Also used : DictionaryItem(zemberek.morphology.lexicon.DictionaryItem) CurrentGroupContainsAny(zemberek.morphology._morphotactics.Conditions.CurrentGroupContainsAny) ContainsMorpheme(zemberek.morphology._morphotactics.Conditions.ContainsMorpheme)

Example 2 with Morpheme

use of zemberek.morphology._morphotactics.Morpheme in project zemberek-nlp by ahmetaa.

the class StemTransitionGenerator method handleSpecialRoots.

private List<StemTransition> handleSpecialRoots(DictionaryItem item) {
    String id = item.getId();
    AttributeSet<PhoneticAttribute> originalAttrs = calculateAttributes(item.pronunciation);
    StemTransition original, modified;
    MorphemeState unmodifiedRootState = morphotactics.getRootState(item, originalAttrs);
    switch(id) {
        case "içeri_Noun":
        case "içeri_Adj":
        case "dışarı_Adj":
        case "dışarı_Noun":
        case "dışarı_Postp":
        case "yukarı_Noun":
        case "yukarı_Adj":
        case "şura_Noun":
        case "bura_Noun":
        case "ora_Noun":
            original = new StemTransition(item.root, item, originalAttrs, unmodifiedRootState);
            MorphemeState rootForModified;
            switch(item.primaryPos) {
                case Noun:
                    rootForModified = morphotactics.nounLastVowelDropRoot_S;
                    break;
                case Adjective:
                    rootForModified = morphotactics.adjLastVowelDropRoot_S;
                    break;
                // TODO: check postpositive case. Maybe it is not required.
                case PostPositive:
                    rootForModified = morphotactics.adjLastVowelDropRoot_S;
                    break;
                default:
                    throw new IllegalStateException("No root morpheme state found for " + item);
            }
            String m = item.root.substring(0, item.root.length() - 1);
            modified = new StemTransition(m, item, calculateAttributes(m), rootForModified);
            modified.getPhoneticAttributes().add(PhoneticAttribute.ExpectsConsonant);
            modified.getPhoneticAttributes().add(PhoneticAttribute.CannotTerminate);
            return Lists.newArrayList(original, modified);
        case "ben_Pron_Pers":
        case "sen_Pron_Pers":
            original = new StemTransition(item.root, item, originalAttrs, unmodifiedRootState);
            if (item.lemma.equals("ben")) {
                modified = new StemTransition("ban", item, calculateAttributes("ban"), morphotactics.pronPers_Mod_S);
            } else {
                modified = new StemTransition("san", item, calculateAttributes("san"), morphotactics.pronPers_Mod_S);
            }
            original.getPhoneticAttributes().add(PhoneticAttribute.UnModifiedPronoun);
            modified.getPhoneticAttributes().add(PhoneticAttribute.ModifiedPronoun);
            return Lists.newArrayList(original, modified);
        case "demek_Verb":
        case "yemek_Verb":
            original = new StemTransition(item.root, item, originalAttrs, morphotactics.vDeYeRoot_S);
            switch(item.lemma) {
                case "demek":
                    modified = new StemTransition("di", item, calculateAttributes("di"), morphotactics.vDeYeRoot_S);
                    break;
                default:
                    modified = new StemTransition("yi", item, calculateAttributes("yi"), morphotactics.vDeYeRoot_S);
            }
            return Lists.newArrayList(original, modified);
        case "birbiri_Pron_Quant":
        case "çoğu_Pron_Quant":
        case "öbürü_Pron_Quant":
        case "birçoğu_Pron_Quant":
            original = new StemTransition(item.root, item, originalAttrs, morphotactics.pronQuant_S);
            switch(item.lemma) {
                case "birbiri":
                    modified = new StemTransition("birbir", item, calculateAttributes("birbir"), morphotactics.pronQuantModified_S);
                    break;
                case "çoğu":
                    modified = new StemTransition("çok", item, calculateAttributes("çok"), morphotactics.pronQuantModified_S);
                    break;
                case "öbürü":
                    modified = new StemTransition("öbür", item, calculateAttributes("öbür"), morphotactics.pronQuantModified_S);
                    break;
                default:
                    modified = new StemTransition("birçok", item, calculateAttributes("birçok"), morphotactics.pronQuantModified_S);
                    break;
            }
            original.getPhoneticAttributes().add(PhoneticAttribute.UnModifiedPronoun);
            modified.getPhoneticAttributes().add(PhoneticAttribute.ModifiedPronoun);
            return Lists.newArrayList(original, modified);
        default:
            throw new IllegalArgumentException("Lexicon Item with special stem change cannot be handled:" + item);
    }
}
Also used : StemTransition(zemberek.morphology._morphotactics.StemTransition) PhoneticAttribute(zemberek.core.turkish.PhoneticAttribute) MorphemeState(zemberek.morphology._morphotactics.MorphemeState)

Example 3 with Morpheme

use of zemberek.morphology._morphotactics.Morpheme in project zemberek-nlp by ahmetaa.

the class _SingleAnalysis method fromSearchPath.

// Here we generate a _SingleAnalysis from a search path.
public static _SingleAnalysis fromSearchPath(SearchPath searchPath) {
    List<MorphemeSurface> morphemes = new ArrayList<>(searchPath.transitions.size());
    int derivationCount = 0;
    for (SurfaceTransition transition : searchPath.getTransitions()) {
        if (transition.isDerivative()) {
            derivationCount++;
        }
        Morpheme morpheme = transition.getMorpheme();
        // if empty, use the cache.
        if (transition.surface.isEmpty()) {
            MorphemeSurface suffixSurface = emptyMorphemeCache.get(morpheme);
            if (suffixSurface == null) {
                suffixSurface = new MorphemeSurface(morpheme, "");
                emptyMorphemeCache.put(morpheme, suffixSurface);
            }
            morphemes.add(suffixSurface);
            continue;
        }
        MorphemeSurface suffixSurface = new MorphemeSurface(morpheme, transition.surface);
        morphemes.add(suffixSurface);
    }
    int[] groupBoundaries = new int[derivationCount + 1];
    // we assume there is always an IG
    groupBoundaries[0] = 0;
    int morphemeCounter = 0, derivationCounter = 1;
    for (SurfaceTransition transition : searchPath.getTransitions()) {
        if (transition.isDerivative()) {
            groupBoundaries[derivationCounter] = morphemeCounter;
            derivationCounter++;
        }
        morphemeCounter++;
    }
    return new _SingleAnalysis(searchPath.getDictionaryItem(), morphemes, groupBoundaries);
}
Also used : Morpheme(zemberek.morphology._morphotactics.Morpheme) ArrayList(java.util.ArrayList)

Example 4 with Morpheme

use of zemberek.morphology._morphotactics.Morpheme in project zemberek-nlp by ahmetaa.

the class TurkishMorphotactics method connectAdjectiveStates.

private void connectAdjectiveStates() {
    // zero morpheme derivation. Words like "yeşil-i" requires Adj to Noun conversion.
    // Since noun suffixes are not derivational a "Zero" morpheme is used for this.
    // Transition has a HAS_TAIL condition because Adj->Zero->Noun+A3sg+Pnon+Nom) is not allowed.
    adj_ST.addEmpty(adjZeroDeriv_S, Conditions.HAS_TAIL);
    adjZeroDeriv_S.addEmpty(noun_S);
    adjZeroDeriv_S.addEmpty(nVerb_S);
    adj_ST.add(aLy_S, ">cA");
    aLy_S.addEmpty(advRoot_ST);
    adj_ST.add(aAsIf_S, ">cA", new Conditions.ContainsMorpheme(asIf, ly, agt, with, justLike).not());
    aAsIf_S.addEmpty(adj_ST);
    adj_ST.add(aAgt_S, ">cI", new Conditions.ContainsMorpheme(asIf, ly, agt, with, justLike).not());
    aAgt_S.addEmpty(noun_S);
    adj_ST.add(justLike_S, "+msI", new NoSurfaceAfterDerivation().and(new ContainsMorpheme(justLike).not()));
    adj_ST.add(justLike_S, "ImsI", notHave(PhoneticAttribute.LastLetterVowel).and(new NoSurfaceAfterDerivation()).and(new ContainsMorpheme(justLike).not()));
    adj_ST.add(become_S, "lAş", new NoSurfaceAfterDerivation());
    adj_ST.add(acquire_S, "lAn", new NoSurfaceAfterDerivation());
    Condition c1 = new Conditions.PreviousMorphemeIsAny(futPart, pastPart);
    adjAfterVerb_S.addEmpty(aPnon_ST, c1);
    adjAfterVerb_S.add(aP1sg_ST, "Im", c1);
    adjAfterVerb_S.add(aP2sg_ST, "In", c1);
    adjAfterVerb_S.add(aP3sg_ST, "I", c1);
    adjAfterVerb_S.add(aP1pl_ST, "ImIz", c1);
    adjAfterVerb_S.add(aP2pl_ST, "InIz", c1);
    adjAfterVerb_S.add(aP3pl_ST, "lArI", c1);
    adj_ST.add(ness_S, "lI~k");
    adj_ST.add(ness_S, "lI!ğ");
    adjAfterVerb_ST.add(ness_S, "lI~k", new Conditions.PreviousMorphemeIs(aorPart));
    adjAfterVerb_ST.add(ness_S, "lI!ğ", new Conditions.PreviousMorphemeIs(aorPart));
}
Also used : NoSurfaceAfterDerivation(zemberek.morphology._morphotactics.Conditions.NoSurfaceAfterDerivation) ContainsMorpheme(zemberek.morphology._morphotactics.Conditions.ContainsMorpheme) PreviousMorphemeIsAny(zemberek.morphology._morphotactics.Conditions.PreviousMorphemeIsAny)

Example 5 with Morpheme

use of zemberek.morphology._morphotactics.Morpheme in project zemberek-nlp by ahmetaa.

the class TurkishMorphotactics method connectVerbs.

private void connectVerbs() {
    // Imperative.
    verbRoot_S.addEmpty(vImp_S);
    vImp_S.addEmpty(// oku
    vA2sg_ST).add(vA2sg_ST, // oku
    "sAnA").add(vA3sg_ST, // okusun
    "sIn").add(vA2pl_ST, // okuyun
    "+yIn").add(vA2pl_ST, // okuyunuz
    "+yInIz").add(vA2pl_ST, // okuyunuz
    "sAnIzA").add(vA3pl_ST, // okusunlar
    "sInlAr");
    // Causative suffixes
    // Causes Verb-Verb derivation. There are three forms: "t", "tIr" and "Ir".
    // 1- "t" form is used if verb ends with a vowel, or immediately after "tIr" Causative.
    // 2- "tIr" form is used if verb ends with a consonant or immediately after "t" Causative.
    // 3- "Ir" form appears after some specific verbs but currently we treat them as separate verb.
    // such as "pişmek - pişirmek". Oflazer parses them as causative.
    verbRoot_S.add(vCausT_S, "t", has(RootAttribute.Causative_t).or(new Conditions.LastDerivationIs(vCausTır_S)).andNot(new Conditions.LastDerivationIsAny(vCausT_S, vPass_S, vAble_S)));
    verbRoot_S.add(vCausTır_S, ">dIr", has(PhoneticAttribute.LastLetterConsonant).andNot(new Conditions.LastDerivationIsAny(vCausTır_S, vPass_S, vAble_S)));
    vCausT_S.addEmpty(verbRoot_S);
    vCausTır_S.addEmpty(verbRoot_S);
    // Progressive1 suffix. "-Iyor"
    // if last letter is a vowel, this is handled with verbRoot_Prog_S root.
    verbRoot_S.add(vProgYor_S, "Iyor", notHave(PhoneticAttribute.LastLetterVowel));
    // For "aramak", the modified root "ar" connects to verbRoot_Prog_S. Here it is connected to
    // progressive "Iyor" suffix. We use a separate root state for these for convenience.
    verbRoot_Prog_S.add(vProgYor_S, "Iyor");
    vProgYor_S.add(vA1sg_ST, "um").add(vA2sg_ST, "sun").addEmpty(vA3sg_ST).add(vA1pl_ST, "uz").add(vA2pl_ST, "sunuz").add(vA3pl_ST, "lar");
    vProgYor_S.add(vCond_S, "sa").add(vPastAfterTense_S, "du").add(vNarrAfterTense_S, "muş").add(vCopBeforeA3pl_S, "dur").add(vWhile_S, "ken");
    // Progressive - 2 "-mAktA"
    verbRoot_S.add(vProgMakta_S, "mAktA");
    vProgMakta_S.add(vA1sg_ST, "yIm").add(vA2sg_ST, "sIn").addEmpty(vA3sg_ST).add(vA1pl_ST, "yIz").add(vA2pl_ST, "sInIz").add(vA3pl_ST, "lAr");
    vProgMakta_S.add(vCond_S, "ysA").add(vPastAfterTense_S, "ydI").add(vNarrAfterTense_S, "ymIş").add(vCopBeforeA3pl_S, "dIr").add(vWhile_S, "yken");
    // Positive Aorist Tense.
    // For single syllable words, it forms as "ar-er". For others "ir-ır-ur-ür"
    // However there are exceptions to it as well. So dictionary items are marked as Aorist_I and
    // Aorist_A.
    verbRoot_S.add(vAor_S, "Ir", has(RootAttribute.Aorist_I).or(Conditions.HAS_SURFACE));
    verbRoot_S.add(vAor_S, "Ar", has(RootAttribute.Aorist_A).and(Conditions.HAS_NO_SURFACE));
    vAor_S.add(vA1sg_ST, "Im").add(vA2sg_ST, "sIn").addEmpty(vA3sg_ST).add(vA1pl_ST, "Iz").add(vA1pl_ST, "sInIz").add(vA3pl_ST, "lAr");
    vAor_S.add(vPastAfterTense_S, "dI").add(vNarrAfterTense_S, "mIş").add(vCond_S, "sA").add(vCopBeforeA3pl_S, "dIr").add(vWhile_S, "ken");
    // Negative
    verbRoot_S.add(vNeg_S, "mA");
    vNeg_S.addEmpty(vImp_S).add(vPast_S, "dI").add(vFut_S, "yAcA~k").add(vFut_S, "yAcA!ğ").add(vNarr_S, "mIş").add(vProgMakta_S, "mAktA").add(vOpt_S, "yA").add(vDesr_S, "sA").add(vNeces_S, "mAlI").add(vInf1_S, "mAk").add(vInf2_S, "mA").add(vInf3_S, "yIş").add(vActOf_S, "mAcA").add(vPastPart_S, "dI~k").add(vPastPart_S, "dI!ğ").add(vFutPart_S, "yAcA~k").add(vFutPart_S, "yAcA!ğ").add(vPresPart_S, "yAn").add(vNarrPart_S, "mIş").add(vSinceDoingSo_S, "yAlI").add(vByDoingSo_S, "yArAk").add(vHastily_S, "yIver").add(vEverSince_S, "yAgör").add(vAfterDoing_S, "yIp").add(vWhen_S, "yIncA").add(vWithoutBeingAbleToHaveDoneSo_S, "yAmAdAn").add(vAsLongAs_S, "dIkçA").add(vWithoutHavingDoneSo_S, "mAdAn").add(vWithoutHavingDoneSo_S, "mAksIzIn").add(vNotState_S, "mAzlI~k").add(vNotState_S, "mAzlI!ğ").add(vFeelLike_S, "yAsI");
    // Negative form is "m" before progressive "Iyor" because last vowel drops.
    // We use a separate negative state for this.
    verbRoot_S.add(vNegProg1_S, "m");
    vNegProg1_S.add(vProgYor_S, "Iyor");
    // Negative Aorist
    // Aorist tense forms differently after negative. It can be "z" or empty.
    vNeg_S.add(vAorNeg_S, "z");
    vNeg_S.addEmpty(vAorNegEmpty_S);
    vAorNeg_S.add(vA2sg_ST, "sIn").addEmpty(vA3sg_ST).add(vA2pl_ST, "sInIz").add(vA3pl_ST, "lAr").add(vPastAfterTense_S, "dI").add(vNarrAfterTense_S, "mIş").add(vCond_S, "sA").add(vCopBeforeA3pl_S, "dIr").add(vWhile_S, "ken");
    vAorNegEmpty_S.add(vA1sg_ST, "m").add(vA1pl_ST, "yIz");
    // okuma-maz-ım
    vNeg_S.add(vAorPartNeg_S, "z");
    vAorPartNeg_S.addEmpty(adjAfterVerb_ST);
    // Positive Ability.
    // This makes a Verb-Verb derivation.
    verbRoot_S.add(vAble_S, "+yAbil", new Conditions.LastDerivationIs(vAble_S).not());
    vAble_S.addEmpty(verbRoot_S);
    // Negative ability.
    verbRoot_S.add(vAbleNeg_S, "+yA");
    // Also for ability that comes before negative, we add a new root state.
    // From there only negative connections is possible.
    vAbleNeg_S.addEmpty(vAbleNegDerivRoot_S);
    vAbleNegDerivRoot_S.add(vNeg_S, "mA");
    vAbleNegDerivRoot_S.add(vNegProg1_S, "m");
    // it is possible to have abil derivation after negative.
    vNeg_S.add(vAble_S, "yAbil");
    // Infinitive 1 "mAk"
    // Causes Verb to Noun derivation. It is connected to a special noun root state.
    verbRoot_S.add(vInf1_S, "mA~k");
    vInf1_S.addEmpty(nounInf1Root_S);
    // Infinitive 2 "mA"
    // Causes Verb to Noun derivation.
    verbRoot_S.add(vInf2_S, "mA");
    vInf2_S.addEmpty(noun_S);
    // Infinitive 3 "+yUş"
    // Causes Verb to Noun derivation.
    verbRoot_S.add(vInf3_S, "+yIş");
    vInf3_S.addEmpty(noun_S);
    // Agt 3 "+yIcI"
    // Causes Verb to Noun and Adj derivation.
    verbRoot_S.add(vAgt_S, "+yIcI");
    vAgt_S.addEmpty(noun_S);
    vAgt_S.addEmpty(adjAfterVerb_ST);
    // ActOf "mAcA"
    // Causes Verb to Noun and Adj derivation.
    verbRoot_S.add(vActOf_S, "mAcA");
    vActOf_S.addEmpty(nounActOfRoot_S);
    // PastPart "oku-duğ-um"
    verbRoot_S.add(vPastPart_S, ">dI~k");
    verbRoot_S.add(vPastPart_S, ">dI!ğ");
    vPastPart_S.addEmpty(noun_S);
    vPastPart_S.addEmpty(adjAfterVerb_S);
    // FutPart "oku-yacağ-ım kitap"
    verbRoot_S.add(vFutPart_S, "+yAcA~k");
    verbRoot_S.add(vFutPart_S, "+yAcA!ğ");
    vFutPart_S.addEmpty(noun_S, Conditions.HAS_TAIL);
    vFutPart_S.addEmpty(adjAfterVerb_S);
    // FutPart "oku-yacağ-ım kitap"
    verbRoot_S.add(vNarrPart_S, "mIş");
    vNarrPart_S.addEmpty(adj_ST);
    // AorPart "okunabilir-lik"
    verbRoot_S.add(vAorPart_S, "Ir", has(RootAttribute.Aorist_I).or(Conditions.HAS_SURFACE));
    verbRoot_S.add(vAorPart_S, "Ar", has(RootAttribute.Aorist_A).and(Conditions.HAS_NO_SURFACE));
    vAorPart_S.addEmpty(adjAfterVerb_ST);
    // PresPart
    verbRoot_S.add(vPresPart_S, "+yAn");
    vPresPart_S.addEmpty(noun_S, Conditions.HAS_TAIL);
    // connect to terminal Adj
    vPresPart_S.addEmpty(adjAfterVerb_ST);
    // FeelLike
    verbRoot_S.add(vFeelLike_S, "+yAsI");
    vFeelLike_S.addEmpty(noun_S, Conditions.HAS_TAIL);
    // connect to terminal Adj
    vFeelLike_S.addEmpty(adjAfterVerb_ST);
    // NotState
    verbRoot_S.add(vNotState_S, "mAzlI~k");
    verbRoot_S.add(vNotState_S, "mAzlI!ğ");
    vNotState_S.addEmpty(noun_S);
    // Passive
    // Causes Verb-Verb derivation. Passive morpheme has three forms.
    // 1- If Verb ends with a vowel: "In"
    // 2- If Verb ends with letter 'l' : "InIl"
    // 3- If Verb ends with other consonants: "nIl"
    // When loading dictionary, first and second case items are marked with Passive_In
    verbRoot_S.add(vPass_S, "In", has(RootAttribute.Passive_In).andNot(new Conditions.ContainsMorpheme(pass)));
    verbRoot_S.add(vPass_S, "InIl", has(RootAttribute.Passive_In).andNot(new Conditions.ContainsMorpheme(pass)));
    verbRoot_S.add(vPass_S, "+nIl", new Conditions.PreviousStateIsAny(vCausT_S, vCausTır_S).or(notHave(RootAttribute.Passive_In).andNot(new Conditions.ContainsMorpheme(pass))));
    vPass_S.addEmpty(verbRoot_S);
    // Condition "oku-r-sa"
    vCond_S.add(vA1sg_ST, "m").add(vA2sg_ST, "n").addEmpty(vA3sg_ST).add(vA1pl_ST, "k").add(vA2pl_ST, "nIz").add(vA3pl_ST, "lAr");
    // Past "oku-du"
    verbRoot_S.add(vPast_S, ">dI");
    vPast_S.add(vA1sg_ST, "m").add(vA2sg_ST, "n").addEmpty(vA3sg_ST).add(vA1pl_ST, "k").add(vA2pl_ST, "nIz").add(vA3pl_ST, "lAr");
    vPast_S.add(vCond_S, "ysA");
    // Narrative "oku-muş"
    verbRoot_S.add(vNarr_S, "mIş");
    vNarr_S.add(vA1sg_ST, "Im").add(vA2sg_ST, "sIn").addEmpty(vA3sg_ST).add(vA1pl_ST, "Iz").add(vA2pl_ST, "sInIz").add(vA3pl_ST, "lAr");
    vNarr_S.add(vCond_S, "sA");
    vNarr_S.add(vPastAfterTense_S, "tI");
    vNarr_S.add(vCopBeforeA3pl_S, "tIr");
    vNarr_S.add(vWhile_S, "ken");
    vNarr_S.add(vNarrAfterTense_S, "mIş");
    // Past after tense "oku-muş-tu"
    vPastAfterTense_S.add(vA1sg_ST, "m").add(vA2sg_ST, "n").addEmpty(vA3sg_ST).add(vA1pl_ST, "k").add(vA2pl_ST, "nIz").add(vA3pl_ST, "lAr");
    // Narrative after tense "oku-r-muş"
    vNarrAfterTense_S.add(vA1sg_ST, "Im").add(vA2sg_ST, "sIn").addEmpty(vA3sg_ST).add(vA1pl_ST, "Iz").add(vA2pl_ST, "sInIz").add(vA3pl_ST, "lAr");
    vNarrAfterTense_S.add(vWhile_S, "ken");
    vNarrAfterTense_S.add(vCopBeforeA3pl_S, "tIr");
    // Future "oku-yacak"
    verbRoot_S.add(vFut_S, "+yAcA~k");
    verbRoot_S.add(vFut_S, "+yAcA!ğ");
    vFut_S.add(vA1sg_ST, "Im").add(vA2sg_ST, "sIn").addEmpty(vA3sg_ST).add(vA1pl_ST, "Iz").add(vA2pl_ST, "sInIz").add(vA3pl_ST, "lAr");
    vFut_S.add(vCond_S, "sA");
    vFut_S.add(vPastAfterTense_S, "tI");
    vFut_S.add(vNarrAfterTense_S, "mIş");
    vFut_S.add(vCopBeforeA3pl_S, "tIr");
    vFut_S.add(vWhile_S, "ken");
    // `demek` and `yemek` are special because they are the only two verbs with two letters
    // and ends with a vowel.
    // Their root transform as:
    // No chabge: de-di, de-miş, de-dir
    // Change : di-yecek di-yor de-r
    // "ye" has similar behavior but not the same. Such as "yi-yin" but for "de", "de-yin"
    // TODO: this can be achieved with less repetition.
    RootSurfaceIsAny diYiCondition = new RootSurfaceIsAny("di", "yi");
    RootSurfaceIsAny deYeCondition = new RootSurfaceIsAny("de", "ye");
    Condition cMultiVerb = new Conditions.PreviousMorphemeIsAny(everSince, repeat, almost, hastily, stay, start).not();
    vDeYeRoot_S.add(vFut_S, "yece~k", diYiCondition).add(vFut_S, "yece!ğ", diYiCondition).add(vProgYor_S, "yor", diYiCondition).add(vAble_S, "yebil", diYiCondition).add(vAbleNeg_S, "ye", diYiCondition).add(vInf3_S, "yiş", new RootSurfaceIsAny("yi")).add(vFutPart_S, "yece~k", diYiCondition).add(vFutPart_S, "yece!ğ", diYiCondition).add(vPresPart_S, "yen", diYiCondition).add(vEverSince_S, "yegel", diYiCondition.and(cMultiVerb)).add(vRepeat_S, "yedur", diYiCondition.and(cMultiVerb)).add(vRepeat_S, "yegör", diYiCondition.and(cMultiVerb)).add(vAlmost_S, "yeyaz", diYiCondition.and(cMultiVerb)).add(vStart_S, "yekoy", diYiCondition.and(cMultiVerb)).add(vSinceDoingSo_S, "yeli", diYiCondition).add(vByDoingSo_S, "yerek", diYiCondition).add(vAfterDoing_S, "yip", diYiCondition).add(vWithoutBeingAbleToHaveDoneSo_S, "yemeden", diYiCondition).add(vOpt_S, "ye", diYiCondition);
    vDeYeRoot_S.add(vCausTır_S, "dir", deYeCondition).add(vPass_S, "n", deYeCondition).add(vPass_S, "nil", deYeCondition).add(vPast_S, "di", deYeCondition).add(vNarr_S, "miş", deYeCondition).add(vAor_S, "r", deYeCondition).add(vNeg_S, "me", deYeCondition).add(vNegProg1_S, "m", deYeCondition).add(vProgMakta_S, "mekte", deYeCondition).add(vDesr_S, "se", deYeCondition).add(vInf1_S, "mek", deYeCondition).add(vInf2_S, "me", deYeCondition).add(vInf3_S, "yiş", new RootSurfaceIsAny("de")).add(vPastPart_S, "di~k", deYeCondition).add(vPastPart_S, "di!ğ", deYeCondition).add(vNarrPart_S, "miş", deYeCondition).add(vHastily_S, "yiver", diYiCondition.and(cMultiVerb)).add(vAsLongAs_S, "dikçe").add(vWithoutHavingDoneSo_S, "meden").add(vWithoutHavingDoneSo_S, "meksizin").add(vNeces_S, "meli").add(vNotState_S, "mezli~k").add(vNotState_S, "mezli!ğ").addEmpty(vImp_S, deYeCondition);
    // Optative (gel-e, gel-eyim gel-me-ye-yim)
    verbRoot_S.add(vOpt_S, "+yA");
    vOpt_S.add(vA1sg_ST, "yIm").add(vA2sg_ST, "sIn").addEmpty(vA3sg_ST).add(vA1pl_ST, "lIm").add(vA2pl_ST, "sInIz").add(vA3pl_ST, "lAr").add(vPastAfterTense_S, "ydI").add(vNarrAfterTense_S, "ymIş");
    // Desire (gel-se, gel-se-m gel-me-se-m)
    verbRoot_S.add(vDesr_S, "sA");
    vDesr_S.add(vA1sg_ST, "m").add(vA2sg_ST, "n").addEmpty(vA3sg_ST).add(vA1pl_ST, "k").add(vA2pl_ST, "nIz").add(vA3pl_ST, "lAr").add(vPastAfterTense_S, "ydI").add(vNarrAfterTense_S, "ymIş");
    verbRoot_S.add(vNeces_S, "mAlI");
    vNeces_S.add(vA1sg_ST, "yIm").add(vA2sg_ST, "sIn").addEmpty(vA3sg_ST).add(vA1pl_ST, "yIz").add(vA2pl_ST, "sInIz").add(vA3pl_ST, "lAr").add(vPastAfterTense_S, "ydI").add(vNarrAfterTense_S, "ymIş").add(vCopBeforeA3pl_S, "dIr").add(vWhile_S, "yken");
    // A3pl exception case.
    // A3pl can appear before or after some tense suffixes.
    // "yapar-lar-dı" - "yapar-dı-lar"
    // For preventing "yapar-dı-lar-dı", conditions are added.
    Condition previousNotPastNarrCond = new PreviousStateIsAny(vPastAfterTense_S, vNarrAfterTense_S, vCond_S).not();
    vA3pl_ST.add(vPastAfterTense_ST, "dI", previousNotPastNarrCond);
    vA3pl_ST.add(vNarrAfterTense_ST, "mIş", previousNotPastNarrCond);
    vA3pl_ST.add(vCond_ST, "sA", previousNotPastNarrCond);
    Condition a3plCopWhile = new PreviousMorphemeIsAny(prog1, prog2, neces, fut, narr, aor);
    vA3pl_ST.add(vCop_ST, "dIr", a3plCopWhile);
    vA3pl_ST.add(vWhile_S, "ken", a3plCopWhile);
    Condition a3sgCopWhile = new PreviousMorphemeIsAny(prog1, prog2, neces, fut, narr, aor);
    vA1sg_ST.add(vCop_ST, "dIr", a3sgCopWhile);
    vA2sg_ST.add(vCop_ST, "dIr", a3sgCopWhile);
    vA3sg_ST.add(vCop_ST, ">dIr", a3sgCopWhile);
    vA1pl_ST.add(vCop_ST, "dIr", a3sgCopWhile);
    vA2pl_ST.add(vCop_ST, "dIr", a3sgCopWhile);
    vCopBeforeA3pl_S.add(vA3pl_ST, "lAr");
    // Allow Past+A2pl+Cond  Past+A2sg+Cond (geldinse, geldinizse)
    Condition previousPast = new Conditions.PreviousMorphemeIs(past).andNot(new ContainsMorpheme(cond, desr));
    vA2pl_ST.add(vCondAfterPerson_ST, "sA", previousPast);
    vA2sg_ST.add(vCondAfterPerson_ST, "sA", previousPast);
    vA1sg_ST.add(vCondAfterPerson_ST, "sA", previousPast);
    vA1pl_ST.add(vCondAfterPerson_ST, "sA", previousPast);
    verbRoot_S.add(vEverSince_S, "+yAgel", cMultiVerb);
    verbRoot_S.add(vRepeat_S, "+yAdur", cMultiVerb);
    verbRoot_S.add(vRepeat_S, "+yAgör", cMultiVerb);
    verbRoot_S.add(vAlmost_S, "+yAyaz", cMultiVerb);
    verbRoot_S.add(vHastily_S, "+yIver", cMultiVerb);
    verbRoot_S.add(vStay_S, "+yAkal", cMultiVerb);
    verbRoot_S.add(vStart_S, "+yAkoy", cMultiVerb);
    vEverSince_S.addEmpty(verbRoot_S);
    vRepeat_S.addEmpty(verbRoot_S);
    vAlmost_S.addEmpty(verbRoot_S);
    vHastily_S.addEmpty(verbRoot_S);
    vStay_S.addEmpty(verbRoot_S);
    vStart_S.addEmpty(verbRoot_S);
    vA3sg_ST.add(vAsIf_S, ">cAsInA", new Conditions.PreviousMorphemeIsAny(aor, narr));
    verbRoot_S.add(vWhen_S, "+yIncA");
    verbRoot_S.add(vSinceDoingSo_S, "+yAlI");
    verbRoot_S.add(vByDoingSo_S, "+yArAk");
    verbRoot_S.add(vAdamantly_S, "+yAsIyA");
    verbRoot_S.add(vAfterDoing_S, "+yIp");
    verbRoot_S.add(vWithoutBeingAbleToHaveDoneSo_S, "+yAmAdAn");
    verbRoot_S.add(vAsLongAs_S, ">dIkçA");
    verbRoot_S.add(vWithoutHavingDoneSo_S, "mAdAn");
    verbRoot_S.add(vWithoutHavingDoneSo_S, "mAksIzIn");
    vAsIf_S.addEmpty(advRoot_ST);
    vSinceDoingSo_S.addEmpty(advRoot_ST);
    vByDoingSo_S.addEmpty(advRoot_ST);
    vAdamantly_S.addEmpty(advRoot_ST);
    vAfterDoing_S.addEmpty(advRoot_ST);
    vWithoutBeingAbleToHaveDoneSo_S.addEmpty(advRoot_ST);
    vAsLongAs_S.addEmpty(advRoot_ST);
    vWithoutHavingDoneSo_S.addEmpty(advRoot_ST);
    vWhile_S.addEmpty(advRoot_ST);
    vWhen_S.addEmpty(advNounRoot_ST);
}
Also used : PreviousStateIsAny(zemberek.morphology._morphotactics.Conditions.PreviousStateIsAny) ContainsMorpheme(zemberek.morphology._morphotactics.Conditions.ContainsMorpheme) PreviousMorphemeIsAny(zemberek.morphology._morphotactics.Conditions.PreviousMorphemeIsAny) ContainsMorpheme(zemberek.morphology._morphotactics.Conditions.ContainsMorpheme) RootSurfaceIsAny(zemberek.morphology._morphotactics.Conditions.RootSurfaceIsAny) PreviousMorphemeIsAny(zemberek.morphology._morphotactics.Conditions.PreviousMorphemeIsAny)

Aggregations

ContainsMorpheme (zemberek.morphology._morphotactics.Conditions.ContainsMorpheme)3 PreviousMorphemeIsAny (zemberek.morphology._morphotactics.Conditions.PreviousMorphemeIsAny)2 ArrayList (java.util.ArrayList)1 PhoneticAttribute (zemberek.core.turkish.PhoneticAttribute)1 CurrentGroupContainsAny (zemberek.morphology._morphotactics.Conditions.CurrentGroupContainsAny)1 NoSurfaceAfterDerivation (zemberek.morphology._morphotactics.Conditions.NoSurfaceAfterDerivation)1 PreviousStateIsAny (zemberek.morphology._morphotactics.Conditions.PreviousStateIsAny)1 RootSurfaceIsAny (zemberek.morphology._morphotactics.Conditions.RootSurfaceIsAny)1 Morpheme (zemberek.morphology._morphotactics.Morpheme)1 MorphemeState (zemberek.morphology._morphotactics.MorphemeState)1 StemTransition (zemberek.morphology._morphotactics.StemTransition)1 DictionaryItem (zemberek.morphology.lexicon.DictionaryItem)1