Skip to main content

Kefir is a natural language processing kit for Turkic languages

Project description




Yogurt is a free software community established at Mustafa Akgül Free Software Camp of 2018.

Kefir is a natural language processing kit for Turkic languages, and maybe Finnish and Hungarian in phonology.


There are two competing notions of the predicate in theories of grammar. The competition between these two concepts has generated confusion concerning the use of the term predicate in theories of grammar.

Kefir is designed to construct sentences by using predicate-logic.

>>> ayni = subject('aynı')
>>> havuc = subject('havuç')
>>> gel = predicate('gel', 'third', 'perfective')
>>> yap = predicate('yap', 'third', 'perfective')
>>> dal = predicate('dal', 'third', 'progressive')
>>> dal = predicate(dal, 'third', 'perfective')

>>> birisi = subject('yakup')
>>> [sentence(birisi, eylem) for eylem in (yap, dal,)]
['yakup yaptı', 'yakup dalmaktaydı']

>>> [sentence(havuc, eylem) for eylem in (gel, yap, dal)]
['havuç geldi', 'havuç yaptı', 'havuç dalmaktaydı']

>>> sebze = predicate(locative('marul'), 'first', 'perfective', True)
>>> dal = predicate(locative('dal'), 'first', 'perfective', True)
>>> [sentence(ayni, eylem) for eylem in (sebze, dal)]
['aynı maruldaydık', 'aynı daldaydık']


  • nominative
  • genitive
  • dative
  • accusative
  • ablative
  • locative


  • negative
  • zero
  • tobe
  • personal
  • perfective
  • imperfective
  • progressive
  • necessitative
  • future
  • impotential
  • conditional

Grammatical Cases

Implemented 6 grammatical cases:

  • Nominative
  • Genitive
  • Dative
  • Accusative
  • Ablative
  • Locative

Turkish has 9 more:

  • Essive
  • Instrumental
  • Inclusive
  • Abessive
  • Likeness
  • Coverage
  • Qualitative
  • Conditional
  • Possesive

📖 Read more on: Turkish Cases.

TODO: Enum'lardaki rakamlar yerine auto() kullanılmalı.

Nominative Case ('Yalın' in Turkish)

The simplest grammatical case, there's no suffix to affix in that case.

Nominative comes from Latin cāsus nominātīvus means case for naming.

Ablative Case ('Ayrılma' in Turkish)

A grammatical case for nouns, pronouns and adjectives in the grammar of various languages; it is sometimes used to express motion away from something, among other uses.

✎︎ Examples:

adalar[dan] geldim
merkez[den] geçtim
teyit[ten] geçtim
açlık[tan] öldüm

Accusative ('İlgi' in Turkish)

The accusative case (abbreviated acc) of a noun is the grammatical case used to mark the direct object of a transitive verb. The same case is used in many languages for the objects of (some or all) prepositions.

✎︎ Examples:

aday[ı] yedim
evim[i] yaptım
üzüm[ü] pişirdim

Genitive Case ('Genitifler' in Turkish)

In grammar, the genitive is the grammatical case that marks a word, usually a noun, as modifying another word, also usually a noun.

✎︎ Examples:

hanımelinin çiçeği (flower of a plant called hanımeli)
kadının ayakkabısı (shoes of the woman)
باب بيت bābu baytin (the door of a house)
mari[i] nie ma w domu (maria is not at home)

Dative Case ('Yönelme' in Turkish)

In some languages, the dative is used to mark the indirect object of a sentence.

✎︎ Examples:

marya yakup'a bir drink verdi (maria gave jacob a drink)
maria jacobī potum dedit (maria gave jacob a drink)

Locative Case ('Bulunma' in Turkish)

Locative is a grammatical case which indicates a location. It corresponds vaguely to the English prepositions "in", "on", "at", and "by".

✎︎ Examples:

bahçe[de] hanımeli var.
yorum[da] iyi beatler var.
kalem[de] güzel uç var.


Turkish Phonology

In Hungarian, Finnish, and Turkic languages vowel sounds are organized in a concept called vowel harmony. Vowels may be classified as Back or Front vowels, based on the placement of the sound in the mouth.

 Front Vowels
 Unrounded  ⟨e⟩ ⟨i⟩
 Rounded    ⟨ü⟩ ⟨ö⟩

 Back Vowels
 Unrounded  ⟨a⟩ ⟨ı⟩
 Rounded    ⟨u⟩ ⟨o⟩

TODO: Document consonant harmony.


Swaps front sounds to back, and vice versa.

>>> swap_front_and_back('acak')

>>> swap_front_and_back('ocok')

>>> swap_front_and_back('öcök')

>>> swap_front_and_back('acak')

Voicing or Sonorization ('Yumuşama' in Turkish)

To make pronouncation easier, nouns ending with these sounds:

⟨p⟩ ⟨ç⟩ ⟨t⟩ ⟨k⟩

May be softened by replacing them in order:

⟨b⟩ ⟨c⟩ ⟨d⟩ ⟨ğ⟩

✎︎ Examples:

ço⟨p⟩un → ço⟨b⟩un
ağa⟨ç⟩ın → ağa⟨c⟩n
kağı⟨t⟩ın → kağı⟨d⟩ın
ren⟨k⟩in → ren⟨g⟩in

✎︎ Examples in other languages:

li⟨f⟩e → li⟨v⟩e
stri⟨f⟩e → stri⟨v⟩e
proo⟨f⟩ → pro⟨v⟩e

Devoicing or Desonorization ('Sertleşme' in Turkish)

To make pronouncation easier, nouns ending with these sounds:

⟨p⟩ ⟨ç⟩ ⟨t⟩ ⟨k⟩

May be hardened by replacing them in order:

⟨b⟩ ⟨c⟩ ⟨d⟩ ⟨ğ⟩

✎︎ Examples:

ço⟨p⟩un → ço⟨b⟩un
ağa⟨ç⟩ın → ağa⟨c⟩n
kağı⟨t⟩ın → kağı⟨d⟩ın
ren⟨k⟩in → ren⟨g⟩in

✎︎ Examples in Other Languages:

dogs → dogs ([ɡz])
missed → missed ([st])
whizzed → whizzed ([zd])
prośba → prɔʑba
просьба → prozʲbə


Turkish Predication and Copula

Turkish language copulas, called 'ek-eylem' (literally 'suffix-verb'), are one of the most distinct features of Turkish grammar.

TODO: Remove unused imports.

Zero Copula

Zero copula is the rule for third person, as in Hungarian and Russian. That means two nouns, or a noun and an adjective can be juxtaposed to make a sentence without using any copula. Third person plural might be indicated with the use of plural suffix "-lar/-ler".

✎︎ Examples:

yogurt kültür (yogurt [is-a] culture)
abbas yolcu (abbas [is-a] traveller)
evlerinin önü yonca (the front of their home [is-a] plant called yonca)

✎︎ Tests:

>>> zero('yolcu')


Negation is indicated by the negative copula 'değil'. 'Değil' is never used as a suffix, but it takes suffixes according to context.

✎︎ Examples:

yogurt kültür değildir (yogurt [is-not-a] culture)
abbas yolcu değildir (abbas [is-not-a] traveller)
evlerinin önü yonca değildir (the front of their home [is-not-a] yonca)

✎︎ Tests:

>>> negative('yolcu')
'yolcu değil'

To Be

Turkish "to be" as regular/auxiliary verb ('olmak').

✎︎ Examples:

yogurt kültürdür (yogurt [is] culture)
abbas yolcudur (abbas [is] traveller)
evlerinin önü yoncadır (the front of their home [is] plant called yonca)

✎︎ Tests:

>>> tobe('yolcu')
>>> tobe('üzüm')
>>> tobe('yonca')

Personification Copula

✎︎ Examples:

ben buralıyım (i'm from here)
sen oralısın (you're from over there)
aynı gezegenliyiz (we're from same planet)

✎︎ Tests:

>>> personal('uçak', Person.FIRST, is_plural=False)

>>> personal('oralı', Person.SECOND, is_plural=False)

>>> personal('gezegenli', Person.FIRST, is_plural=True)

Inferential Mood ('-miş' in Turkish)

Inferential mood is used to convey information about events which were not directly observed or were inferred by the speaker.

✎︎ Examples:

elmaymışım (i was an apple as i've heard)
üzülmüşsün (you were sad as i've heard)
doktormuş (he/she/it was a doctor as i've heard)
üzümmüşsün (you were a grape as i've heard)

✎︎ Tests:

>>> inferential('öğretmen', Person.SECOND, is_plural=False)

>>> inferential('üzül', Person.SECOND, is_plural=False)

>>> inferential('robot', Person.FIRST, is_plural=False)

>>> inferential('robot', Person.THIRD, is_plural=False)

>>> inferential('ada', Person.THIRD, is_plural=False)

Inferential Mood ('-isem' in Turkish)

Inferential mood is a grammatical mood used to express a proposition whose validity is dependent on some condition, possibly counterfactual.

✎︎ Examples:

elmaysam (if i am an apple)
üzümsen (if you are a grape)
bıçaklarsa (if they are a knife)

✎︎ Tests:

>>> conditional('elma', Person.FIRST, is_plural=False)
>>> conditional('üzüm', Person.SECOND, is_plural=False)
>>> conditional('bıçak', Person.THIRD, is_plural=True)

Alethic Modality ('-idi' in Turkish)

Linguistic modality that indicates modalities of truth, in particular the modalities of logical necessity, possibility or impossibility.

✎︎ Examples:

elmaydım (i was an apple)
üzümdün (you were a grape)
doktordu (he/she/it was a doctor)

✎︎ Tests:

>>> perfective('açık', Person.FIRST, is_plural=False)

>>> perfective('oralı', Person.SECOND, is_plural=False)

>>> perfective('dalda', Person.FIRST, is_plural=False)

>>> perfective('dalda', Person.THIRD, is_plural=False)

>>> perfective('dalda', Person.FIRST, is_plural=True)

>>> perfective('dalda', Person.SECOND, is_plural=True)

>>> perfective('dalda', Person.THIRD, is_plural=True)

>>> perfective('gezegende', Person.THIRD, is_plural=True)

The Imperfective ('-iyor' in Turkish)

Grammatical aspect used to describe a situation viewed with interior composition. It describes ongoing, habitual, repeated, or similar semantic roles, whether that situation occurs in the past, present, or future.

✎︎ Examples:

gidiyorum (i'm going)
kayıyor (he's skating)
üzümlüyor (he's graping)

✎︎ Tests:

>>> imperfective('açı', Person.FIRST, is_plural=False)

>>> imperfective('açık', Person.FIRST, is_plural=False)

>>> imperfective('oralı', Person.SECOND, is_plural=False)

>>> imperfective('dal', Person.THIRD, is_plural=False)

>>> imperfective('dal', Person.FIRST, is_plural=True)

>>> imperfective('dal', Person.FIRST, is_plural=True)

>>> imperfective('dal', Person.SECOND, is_plural=True)

>>> imperfective('dal', Person.THIRD, is_plural=True)

The Future Tense ('-iyor' in Turkish)

The future tense is a verb form that generally marks the event described by the verb as not having happened yet, but expected to happen in the future.

✎︎ Examples:

gidecek (he'll go)
ölecek (he'll die)
can alacak (he'll kill someone)

✎︎ Tests:

>>> future('gel', Person.FIRST, is_plural=False)

>>> future('açık', Person.FIRST, is_plural=False)

>>> future('gel', Person.FIRST, is_plural=True)

Progressive Tense

✎︎ Examples: gülmekteyim (i am in the process of laughing) ölmekteler (they are in the process of dying 👾)

✎︎ Tests:

>>> progressive('gel', Person.FIRST, is_plural=False)

>>> progressive('açık', Person.FIRST, is_plural=False)

>>> progressive('gel', Person.FIRST, is_plural=True)

Necessitative Copula

✎︎ Examples:

gitmeliyim (i must go)
kaçmalıyım (i must run away)

✎︎ Tests:

>>> necessitative('git', Person.FIRST, is_plural=False)

>>> necessitative('açık', Person.FIRST, is_plural=False)

>>> necessitative('uza', Person.FIRST, is_plural=True)

Impotential Copula

✎︎ Examples:

gidemem (i cannot come)
kaçamayız (we cannot run away)

✎︎ Tests:

>>> impotential('git', Person.FIRST, is_plural=False)

>>> impotential('git', Person.SECOND, is_plural=False)

>>> impotential('git', Person.THIRD, is_plural=False)

>>> impotential('git', Person.FIRST, is_plural=True)

>>> impotential('git', Person.FIRST, is_plural=True)

>>> impotential('git', Person.SECOND, is_plural=True)

>>> impotential('git', Person.THIRD, is_plural=True)

>>> impotential('al', Person.THIRD, is_plural=True)


Contribution Guide

  • Don't load a fixture, code is our data.
  • Don't leave a comment! Docstrings are only for the context and test.
  • Be nice 🦄


  • Berk Buzcu (8-bit artwork)
  • Serdar Açıkyol (Illustration)
  • Fatih Erikli (Phonological Processes, Predicate Logic)
  • Armagan Amcalar (Javascript Port)
  • Umut Karcı (Packaging and Versioning)
  • Kerem Bozdaş (Editing)


This project is licensed under the terms of the MIT license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kefir-0.1.3.tar.gz (30.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page