Search in sources :

Example 1 with AttributeSet

use of zemberek.morphology.morphotactics.AttributeSet in project zemberek-nlp by ahmetaa.

the class AttributesHelper method getMorphemicAttributes.

public static AttributeSet<PhoneticAttribute> getMorphemicAttributes(CharSequence seq, AttributeSet<PhoneticAttribute> predecessorAttrs) {
    if (seq.length() == 0) {
        return predecessorAttrs.copy();
    }
    AttributeSet<PhoneticAttribute> attrs = new AttributeSet<>();
    if (alphabet.containsVowel(seq)) {
        TurkicLetter last = alphabet.getLastLetter(seq);
        if (last.isVowel()) {
            attrs.add(LastLetterVowel);
        } else {
            attrs.add(LastLetterConsonant);
        }
        TurkicLetter lastVowel = last.isVowel() ? last : alphabet.getLastVowel(seq);
        if (lastVowel.isFrontal()) {
            attrs.add(LastVowelFrontal);
        } else {
            attrs.add(LastVowelBack);
        }
        if (lastVowel.isRounded()) {
            attrs.add(LastVowelRounded);
        } else {
            attrs.add(LastVowelUnrounded);
        }
        if (alphabet.getFirstLetter(seq).isVowel()) {
            attrs.add(FirstLetterVowel);
        } else {
            attrs.add(FirstLetterConsonant);
        }
    } else {
        // we transfer vowel attributes from the predecessor attributes.
        attrs.copyFrom(predecessorAttrs);
        attrs.addAll(NO_VOWEL_ATTRIBUTES);
        attrs.remove(LastLetterVowel);
        attrs.remove(ExpectsConsonant);
    }
    TurkicLetter last = alphabet.getLastLetter(seq);
    if (last.isVoiceless()) {
        attrs.add(LastLetterVoiceless);
        if (last.isStopConsonant()) {
            // kitap
            attrs.add(LastLetterVoicelessStop);
        }
    } else {
        attrs.add(LastLetterVoiced);
    }
    return attrs;
}
Also used : TurkicLetter(zemberek.core.turkish.TurkicLetter) AttributeSet(zemberek.morphology.morphotactics.AttributeSet) PhoneticAttribute(zemberek.core.turkish.PhoneticAttribute)

Aggregations

PhoneticAttribute (zemberek.core.turkish.PhoneticAttribute)1 TurkicLetter (zemberek.core.turkish.TurkicLetter)1 AttributeSet (zemberek.morphology.morphotactics.AttributeSet)1