Turkish Stemmer for Python
Note : Most of the documentation taken from elasticsearch-analysis-turkishstemmer project.
Stemmer algorithm for Turkish language.
Introduction to Turkish language morphology
Turkish is an agglutinative language and has a very rich morphological stucture. In Turkish, you can form many different words from a single stem by appending a sequence of suffixes. For example The word "doktoruymuşsunuz" means "You had been the doctor of him". The stem of the word is "doktor" and it takes three different suffixes -sU, -ymUş, and -sUnUz.
From "Snowball Description":
Words are usually composed of a stem and of at least two or three affixes appended to it.
We can analyze noun suffixes in Turkish in two groups. Noun suffixes (eg. "doktor-um" meaning "my doctor") and nominal verb suffixes (eg. "doktor-dur" meaning ‘is a doctor’). The words ending with nominal verb suffixes can be used as verbs in sentences. There are over thirty different suffixes classified in these two general groups of suffixes.
In Turkish, the suffixes are affixed to the stem according to definite ordering rules.
From "An affix stripping morphological analyzer for Turkish" paper:
Turkish has a special place within the natural languages not only being a fully concatenative language but also having the suffixes as the only affix type. Another feature of the language is that, someone who knows Turkish can easily analyze a word even if he/she does not know its stem.
The phonological rules of Turkish are significant factors that influence this feature. Ex: (any word)lerim => (any word)-ler-im "ler" plural suffix, "im" 1st singular person possessive.
The only affix type in Turkish is the suffix.
A plural suffix cannot follow a possesive suffix.
A suffix in Turkish can have multiple allomorphs in order to provide sound harmony in the word to which it is affixed.
In Turkish each vowel indicates a distinct syllable.
In Turkish, single syllable words are mostly the stem itself
If a word has nominal verb suffixes, they always appear at the end of the word. They follow noun suffixes or the stem itself at the absence of noun suffixes
In Turkish, “-lAr” suffix can be used both as a nominal verb suffix (third person plural present tense) and as a noun suffix (plural inflection).
In Turkish, words do not end with consonants 'b', 'c', 'd', and 'ğ'. However, when a suffix starting with a vowel is affixed to a word ending with 'p', 'ç', 't' or 'k', the last consonant is transformed into 'b', 'c', 'd', or 'ğ' respectively. The postlude routine transforms last consonants 'b', 'c','d', or 'ğ'' back to 'p', 'ç', 't' or 'k', respectively, after stemming is complete.
|Nominal verb suffixes||Inflectional|
|Tense & person verb suffixes||Inflectional|
Suffix allomorphs are used to create a good sound harmony. They do not change the meaning of the word. If a suffix has a capital letter then it has an allomorh. If a suffix has a letter in parentheses then it can be omitted. Possible allomorphs are given below:
Nominal Verb Suffixes
Suffix transition ordering for nominal verbs can be seen in References
Suffix transition ordering for nouns can be seen in References
Initially, we will handle only a small subset of the above suffixes which are more common in our domain.
This routine checks whether the last two vowels of the word obey vowel harmony rules. A brief description of Turkish vowel harmony follows.
Turkish vowel harmony is a two dimensional vowel harmony system, where vowels are characterised by two features named frontness and roundness. There are vowel harmony rules for each feature.
Vowel harmony rule for frontness: Vowels in Turkish are grouped into two according to where they are produced. Front produced vowels are formed at the front of the mouth ('e', 'i', 'ö', 'ü') and back produced vowels are produced nearer to throat ('a', 'ı', 'o', 'u'). According to the vowel harmony rule, words cannot contain both front and back vowels. This is one of the reasons why suffixes containing vowels can take different forms to obey vowel harmony.
Vowel harmony rule for roundness: Vowels in Turkish are grouped into two according to whether lips are rounded while producing it. 'o', 'ö', 'u' and 'ü' are rounded vowels whereas 'a', 'e', 'ı' and 'i' are unrounded. According to the vowel harmony rules, if the vowel of a syllable is unrounded, the following vowel is unrounded as well. If the vowel of a syllable is rounded, the following vowels are 'a', 'e', 'u' or 'ü'.
Another interesting case in detecting suffixes in Turkish is that, for some suffixes, if the word ends with a vowel, a consonant is inserted between the rest of the word and the suffix. These merging consonants can be 'y', 'n' or 's'. When a merging consonant can be inserted before the suffix, the representation of the suffix starts with the optional consonant surrounded by paranthesis (eg. –(y)Um, -(n)cA). For these kinds of suffixes, if existence of a merging consonant is considered, the candidate stem is checked whether it ends with a vowel.
If there is no 'y' consonant before the suffix, only the real part of the suffix (eg. -Um) is marked for stemming. If there is a 'y' consonant and it is preceded by a vowel, 'y' is treated as a merging consonant and both 'y' and the candidate suffix (eg. -Um) is marked for stemming. If there is a consonant just before 'y', the decision is that the consonant 'y' and the candidate suffix are really a part of the stem. In such a case, cursor is not advanced to prevent over-stemming. The last case can occur especially when the stem originates from another language like in 'lityum' (meaning the element Lithium). If the check for vowel harmony was not made, the word would be stemmed to 'lit', for '–(y)Um' would be treated as a suffix affixed to it. But according to morphological rules of Turkish, the final word would be 'litim', not 'lityum' if 'lit' were really the stem of the word and the suffix '–(y)Um' were affixed to it. So detecting 'lit' as the stem of the word would be an over -stemming.
Similar to merging consonants, there are merging vowels for some suffixes starting with consonants. They can be preceded by merging vowels like in '-(U) mUz' suffix when they are affixed to a stem ending with a consonant. In such a case, a U vowel ('ı', 'i', 'u' or 'ü' depending on vowel harmony) is inserted between the stem and real suffix (e.g. '-mUz') for ease of pronunciation.
|Word / Analysis||Meaning / Stem|
|Kalelerimizdekilerden||From the ones at one of our castles|
|Çocuğuymuşumcasına||As if I were her child|
|Kedileriyle||With their cats|
|Çocuklarımmış||Someone told me that they were my children|
|Kitabımızdı||It was our book|
- Add more verbs suffixes.
- Add more derivational suffixes.
- Turkish Stemmer used in Lucene
- Java Implementation
- Snowball Implementation
- Snowball Description
- An affix stripping morphological analyzer for Turkish
- Lead Generation
- Vowel Harmony
- Turkish Suffixes
- Turkish Grammar
- Turkish Language
- Information Retrieval on Turkish Texts
Copy the module folder inside PythonXX/Lib/site-packages or inside your application directory.
>>> from TurkishStemmer import TurkishStemmer >>> stemmer = TurkishStemmer() >>> stemmer.stem("okuldakilerden") okul
- Fork it (
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
turkishstemmer-python is licensed under the Apache Software License, Version 2.0.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash||File type||Python version||Upload date|
|TurkishStemmer-1.3-py3-none-any.whl (20.6 kB) View hashes||Wheel||py3|
|TurkishStemmer-1.3.tar.gz (16.7 kB) View hashes||Source||None|
Hashes for TurkishStemmer-1.3-py3-none-any.whl