TurkishStemmer plugin for Elasticsearch
Stemmer algorithm for Τurkish 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
To list all plugins in current installation:
sudo bin/elasticsearch-plugin list
In order to install the latest version of the plugin, simply run:
sudo bin/elasticsearch-plugin install gr.skroutz:elasticsearch-analysis-turkishstemmer:22.214.171.124
In order to install the plugin for version 2.4.4, run:
sudo bin/plugin install gr.skroutz/elasticsearch-analysis-turkishstemmer/126.96.36.199
In order to install the plugin for versions prior to 1.5.x, run:
sudo bin/plugin -install gr.skroutz/elasticsearch-analysis-turkishstemmer/0.1.9
To remove a plugin (5.x.x):
sudo bin/elasticsearch-plugin remove <plugin_name>
index: analysis: filter: stem-turkish: type: turkish_stemmer
- 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
elasticsearch-analysis-turkishstemmer is licensed under the Apache Software License, Version 2.0.