Search in sources :

Example 1 with CurrentGroupContainsAny

use of zemberek.morphology._morphotactics.Conditions.CurrentGroupContainsAny 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 CurrentGroupContainsAny

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

the class TurkishMorphotactics method connectVerbAfterPronoun.

private void connectVerbAfterPronoun() {
    pvVerbRoot_S.addEmpty(pvPresent_S);
    pvVerbRoot_S.add(pvPast_S, "+ydI");
    pvVerbRoot_S.add(pvNarr_S, "+ymIş");
    pvVerbRoot_S.add(pvCond_S, "+ysA");
    Condition allowA1sgTrans = new Conditions.PreviousGroupContains(pP1sg_S).not();
    Condition allowA1plTrans = new Conditions.PreviousGroupContains(pP1sg_S, pP2sg_S).not();
    Condition allowA2sgTrans = new Conditions.PreviousGroupContains(pP2sg_S).not();
    Condition allowA2plTrans = new Conditions.PreviousGroupContains(pP2pl_S).not();
    pvPresent_S.add(pvA1sg_ST, "+yIm", allowA1sgTrans);
    pvPresent_S.add(pvA2sg_ST, "sIn", allowA2sgTrans);
    // We do not allow ending with A3sg from empty Present tense.
    pvPresent_S.addEmpty(nA3sg_S);
    pvPresent_S.add(pvA1pl_ST, "+yIz", allowA1plTrans);
    pvPresent_S.add(pvA2pl_ST, "sInIz");
    pvPresent_S.add(pvA3pl_ST, "lAr", new Conditions.PreviousGroupContains(pLoc_ST));
    pvPast_S.add(pvA1sg_ST, "m", allowA1sgTrans);
    pvPast_S.add(pvA2sg_ST, "n", allowA2sgTrans);
    pvPast_S.add(pvA1pl_ST, "k", allowA1plTrans);
    pvPast_S.add(pvA2pl_ST, "InIz");
    pvPast_S.add(pvA3pl_ST, "lAr");
    pvPast_S.addEmpty(pvA3sg_ST);
    pvNarr_S.add(pvA1sg_ST, "Im", allowA1sgTrans);
    pvNarr_S.add(pvA2sg_ST, "sIn", allowA2sgTrans);
    pvNarr_S.add(pvA1pl_ST, "Iz", allowA1plTrans);
    pvNarr_S.add(pvA2pl_ST, "sInIz");
    pvNarr_S.add(pvA3pl_ST, "lAr");
    pvNarr_S.addEmpty(pvA3sg_ST);
    // narr+cons is allowed but not past+cond
    pvNarr_S.add(pvCond_S, "sA");
    pvCond_S.add(pvA1sg_ST, "m", allowA1sgTrans);
    pvCond_S.add(pvA2sg_ST, "n", allowA2sgTrans);
    pvCond_S.add(pvA1pl_ST, "k", allowA1plTrans);
    pvCond_S.add(pvA2pl_ST, "nIz", allowA2plTrans);
    pvCond_S.addEmpty(pvA3sg_ST);
    pvCond_S.add(pvA3pl_ST, "lAr");
    // for not allowing "elma-ydı-m-dır"
    Condition rejectNoCopula = new CurrentGroupContainsAny(pvPast_S, pvCond_S, pvCopBeforeA3pl_S).not();
    // elma-yım-dır
    pvA1sg_ST.add(pvCop_ST, "dIr", rejectNoCopula);
    pvA1pl_ST.add(pvCop_ST, "dIr", rejectNoCopula);
    pvA3sg_S.add(pvCop_ST, ">dIr", rejectNoCopula);
    pvA3pl_ST.add(pvCop_ST, "dIr", rejectNoCopula);
    // Copula can come before A3pl.
    pvPresent_S.add(pvCopBeforeA3pl_S, ">dIr");
    pvCopBeforeA3pl_S.add(pvA3pl_ST, "lAr");
}
Also used : CurrentGroupContainsAny(zemberek.morphology._morphotactics.Conditions.CurrentGroupContainsAny)

Aggregations

CurrentGroupContainsAny (zemberek.morphology._morphotactics.Conditions.CurrentGroupContainsAny)2 ContainsMorpheme (zemberek.morphology._morphotactics.Conditions.ContainsMorpheme)1 DictionaryItem (zemberek.morphology.lexicon.DictionaryItem)1