Monday, May 28, 2012

Turkish I Problem - Part 3 - The Solution

The Turkish I Problem is caused by the mapping of the letter i-I in the Latin character set to two different letters i-İ and ı-I in the Turkish alphabet. A solution should naturally separate out the two letters.

The most widespread existing solution proposal suggests introducing two new characters to Unicode to encode Turkish lowercase i and Turkish uppercase I. These letters look the same as the English versions but they will have different Unicode code points. This will solve the problem but it also introduces other issues. For example you need to type different version of the lowercase letter i when typing Turkish or English. This will be a headache if the text contains mixed words from these languages. It will be next to impossible to fix spelling mistakes involving lowercase i and uppercase I in mixed text. Consider the example from my earlier blog about the subject "Alice Harikalar Diyarında". To write this phrase correctly you need to use different versions of the lowercase letter i and switch between the Turkish and the English alphabets. If you mistype one of the letter i, you cannot see which one is wrong because both look the same.

My solution proposal
- Use characters i-I to replace Turkish i-İ.
- Use characters í-Í to replace Turkish ı-I.

This proposal removes the biggest complication from the Turkish alphabet. It also unifies the Turkish i-I with the Latin i-I avoiding the problems caused by the earlier proposal. Also note that the dot over the letter i is a result of the natural development of the alphabet, removing it in the Turkish alphabet was a mistake in the first place.

The solution has its week points as well. For one, it is changing the mapping of uppercase I. However I believe this is a desirable change in the long run which will bring Turkish closer to being a well behaving member of the Latin character set.

Sample text
Karín sessizliği, diye düşünüyordu otobüste şoförün hemen arkasínda oturan adam. Bu bir şiirin başlangící olsaydí içinde hissettiği şeye karín sessizliği derdi.

Onu Erzurum'dan Kars'a götürecek otobüse son anda yetişmişti, Istanbul'dan iki gün süren karlí fírtínalí bir otobüs yolculuğundan sonra Erzurum garajína varmíş, kirli ve soğuk koridorlarda elinde çantasí, kendisini Kars'a götürecek otobüslerin nereden kalktíğíní öğrenmeye çalíşírken biri, bir otobüsün hemen kalkmakta olduğunu söylemişti.

Yetiştiği Magirus marka eski otobüsün muavini, kapattíğí bagají yeniden açmak istemediği için "Acelemiz var," demişti. Bu yüzden şimdi bacaklarínín arasínda duran koyu vişne rengi Bally marka büyük el çantasíní yanína almíştí. Pencere kenarínda oturan yolcunun üzerinde beş yíl önce Frankfurt'ta bir Kaufhof'tan aldíğí kül rengi kalín bir palto vardí. Kars'ta geçireceği günlerde bu yumuşacík tüylü, güzel paltonun kendisi için hem utanç ve huzursuzluk, hem de güven kaynağí olacağíní şimdiden söyleyelim.

Snow/Kar by Orhan Pamuk
Read Part 1, Part 2

Sunday, May 27, 2012

Turkish I Problem - Part 2 - Of Dots And Men

Why does the lower case letter i has a dot?

When I was reviewing the Turkish alphabet and the letters with diacritics, I noticed that the English alphabet does not use diacritics most of the time. The only exceptions are the lowercase letters i and j. This begs the question "Why does the lower letter i (or j) has a dot?". After all it should have been easier to write and more consistent with the rest of the alphabet if it did not have a dot.

The dot on the lower letter i or j is called the tittle. Wikipedia says the following about it.

Tittle
The tittle first appeared in Latin manuscripts in the 11th century, to distinguish the letter i from strokes of nearby letters. Although originally a larger mark, it was reduced to a dot when Roman-style typefaces were introduced.
Blackletter / Gothic script / Textualis
Minims, especially in the later period of the script, do not connect with each other. This makes it very difficult to distinguish i, u, m, and n. A 14th-century example of the difficulty minims produced is, mimi numinum niuium minimi munium nimium uini muniminum imminui uiui minimum uolunt ("the smallest mimes of the gods of snow do not wish at all in their life that the great duty of the defences of the wine be diminished"). In black letter this would look like a series of single strokes. Dotted i and the letter j developed because of this.

The dates do not match in the articles. However 14th century seems to be the correct one to me, considering that the Gothic script started mid 12 century and the earlier forms of the minuscule (lower case) scripts (Half-Uncial, Carolingian) do not write the letter i with a dot.

On top of all this the dot seems to add more body to this smallest member of the alphabet to make it easier to read.

Here is a summary
  • Early Latin alphabet did not have lowercase. Letter I was written without a dot.
  • Lower case (minuscule) letters appeared after 8th century. Early forms like the Carolingian script continued to write the letter i without a dot.
  • Textualis a form of Gothic script started using the dot in lower case letter i to distinguish it from strokes of letters u, m, and n.
  • The letter j was added to the alphabet as a variation of the letter i. As such it followed the evolution of the letter i.
  • Turkish brought us full circle back by removing the dot from the letter i.

See also
http://en.wikipedia.org/wiki/Tittle
http://en.wikipedia.org/wiki/Lower_case
http://en.wikipedia.org/wiki/Blackletter

Read Part 1, Part 3


Turkish I Problem

Turkish has finally made its fame in the world. Every self respecting software developer needs to know about it these days. The problem is that it is all for the wrong reasons. Turkish is wracking havoc through internationalized software because of a problem in its alphabet design, infamously named the "Turkish I Problem".

Briefly, the problem is caused by Turkish mapping the letter i-I in the Latin character set to two different letters i-İ and ı-I in the Turkish alphabet.

LetterLowercaseUppercase
English IiI
Turkish Dotted Iiİ
Turkish Dotless IıI

These conflicting rules complicate case conversions between upper and lower case text. Computer application use case conversions frequently and they may break when used with Turkish Locale.

As an example consider the popular children's book "Alice Harikalar Diyarında" / "Alice in Wonderland". When converted to uppercase it becomes "ALİCE HARİKALAR DİYARINDA" using Turkish capitalization rules or "ALICE HARIKALAR DIYARINDA" using English capitalization rules. The problem is that both of them are wrong. I have marked the incorrect conversions in red. The correct capitalization should be "ALICE HARİKALAR DİYARINDA", unless we are in the business of translating proper nouns to Turkish too.

As a result any text that mixes Turkish and another language with a Latin based alphabet cannot be case converted easily. Non Turkish names and text in Turkish databases are almost always case converted incorrectly. The reverse is also true.

See also
http://www.i18nguy.com/unicode/turkish-i18n.html
http://www.codinghorror.com/blog/2008/03/whats-wrong-with-turkey.html

Read Part 2, Part 3

Friday, May 25, 2012

Alternative Turkish Q Keyboard Layout

If your keyboard does not mark the keys for the Turkish characters, try using Turkish Q Alt keyboard layout. Turkish Q Alt is a practical alternative to Turkish Q keyboard layout.

Goals of Turkish Q Alt keyboard layout
  • Full compatibility with US English keyboard layout.
  • Can be used when keyboard does not mark where the Turkish characters are.
  • Do not change places for standard ascii letters and punctuation.
  • No dead keys. The ^ key in classic Turkish Q keyboard layout is an example of a dead key.
  • Support â, î, and û as first class citizens.
  • Support new TL sign.
  • It is an alternative to Turkish Q keyboard layout.
  • It is not replacing Turkish F. The official Turkish keyboard layout is Turkish F. If you need to type fast, use Turkish F which set multiple world typing records.

Design

Default (same as US English)


Shift (same as US English)


AltGr (or Ctrl+Alt)


Shift+AltGr (or Shift+Ctrl+Alt)



How to use Turkish Q Alt keyboard layout

Turkish Q Alt is same as the US English keyboard layout with following additions.
  • ç (AltGr+c), Ç (Shift+AltGr+c)
  • ğ (AltGr+g), Ğ (Shift+AltGr+g)
  • ı (AltGr+i), İ (Shift+AltGr+i)
  • ö (AltGr+o), Ö (Shift+AltGr+o)
  • ş (AltGr+s), Ş (Shift+AltGr+s)
  • ü (AltGr+u), Ü (Shift+AltGr+u)

  • â (AltGr+a), Â (Shift+AltGr+a)
  • î (AltGr+k), Î (Shift+AltGr+k). K is one row below i.
  • û (AltGr+j), Û (Shift+AltGr+j). J is one row below u.

  • TL Sign (Shift+AltGr+$).
  • (AltGr+e). This is optional. Included considering trade ties to EU and the pending Turkish membership to EU.

Turkish Q Alt keeps the standard US English layout for all letters and punctuation. Turkish characters are produced by pressing down AltGr and the corresponding ascii keys on the keyboard. AltGr is located on the right side of the space bar. It is marked with the text Alt or AltGr. You can also click Ctrl+Alt key instead of AltGr to produce the same affect. For example to type ş, press down AltGr and s together. For î and û use the keys k and j. These are one row below i and u.

TL Sign is assigned Ux20BA in Unicode 6.2. Unicode 6.2 is scheduled to be released in third quarter of 2012. TL Sign will not display correctly until your operating system is updated with a Unicode 6.2 compatible font. See http://en.wikipedia.org/wiki/Turkish_lira_sign for more info.

Installation for Windows 7
   - Download Turkish Q Alt keyboard layout from https://drive.google.com/uc?export=download&id=0B9xb1-1cqU9YNmdFbXBSWnJZTTA

   - Extract the zip file.
   - Run setup.exe and follow the instructions
   - When installation succeeds you will see a TR sign on the taskbar.

Email me if you can help port Turkish Q Alt to other operating systems.

Tuesday, May 22, 2012

Türkiye İçin İki Harfli İl Kodları

Türkiye'de trafik plakalarında illeri belirtmek için iki rakamdan oluşan bir kod kullanılıyor. İki rakamlı kodlar uygulamaya konulduğu tarihteki 67 ile göre tasarlanmışlar ve baslangıçta alfabe sırasına uyuyorlarmış. 1989 yılından itibaren il olan yerlere il olma tarihlerine göre yeni kodlar verilmiş. 2012 itibariyle Türkiye'de 81 il var. İl kodları artık alfabe sırasına uymuyor ve trafik kodlarından illeri tahmin etmek çok zor.

İki rakamlı il kodları yerine dünyanın birçok yerinde kullanılan iki harften oluşan kodlar öneriyorum. Bu kodlar trafik kodu olarak ya da posta adreslerinde kullanılabilir.

İki harften oluşan il kodları ile:
  • Harf kodlarının hangi ile ait olduğunu bilmek daha kolay olacak.
  • İlk 67 ilden sonra bozulan alfabetik sıra problem olmayacak.
  • Gelecekte il olacak yerler problem olmayacak.
  • Bazı illerin isimlerinin ya da kodlarının gelecekte değişmesi problem olmayacak.
  • İki rakamla 99 il kodlanabilirken iki harfle sadece ASCII harfleri kullanarak 500 den fazla il kodlanabilir.
  • İki harfli kodlar rakamlara göre marka olmaya daha uygun.

İki harfli yeni il kodları
İl Adı    İl kodu        İl Adı    İl kodu        İl Adı    İl kodu
--------  -------        --------  -------        --------  -------
Adana          AD        Edirne         ED        Malatya        ML
Adıyaman       AI        Elazığ         EL        Manisa         MA
Afyonkarahisar AF        Erzincan       EZ        Mardin         MR
Ağrı           AG        Erzurum        ER        Mersin         ME
Aksaray        AK        Eskişehir      ES        Muğla          MU
Amasya         AA        Gaziantep      GA        Muş            MS
Ankara         AN        Giresun        GI        Nevşehir       NS
Antalya        AT        Gümüşhane      GH        Niğde          NI
Ardahan        AH        Hakkâri        HK        Ordu           OR
Artvin         AV        Hatay          HA        Osmaniye       OS
Aydın          AY        Iğdır          IG        Rize           RI
Balıkesir      BA        Isparta        IP        Sakarya        SK
Bartın         BN        İstanbul       IS        Samsun         SA
Batman         BT        İzmir          IZ        Şanlıurfa      SU
Bayburt        BY        Kahramanmaraş  KM        Siirt          ST
Bilecik        BL        Karabük        KB        Sinop          SP
Bingöl         BG        Karaman        KN        Şırnak         SR
Bitlis         BI        Kars           KR        Sivas          SI
Bolu           BO        Kastamonu      KT        Tekirdağ       TD
Burdur         BR        Kayseri        KA        Tokat          TO
Bursa          BU        Kilis          KL        Trabzon        TZ
Çanakkale      CK        Kırıkkale      KK        Tunceli        TU
Çankırı        CN        Kırklareli     KE        Uşak           US
Çorum          CO        Kırşehir       KS        Van            VA
Denizli        DE        Kocaeli        KC        Yalova         YA
Diyarbakır     DB        Konya          KO        Yozgat         YO
Düzce          DU        Kütahya        KU        Zonguldak      ZO

İki harfli il kodlarını seçerken uyguladığım kurallar.
  1. İlk iki harfi başka illerin ilk harflerinden farklı olan iller bu iki harfi kullanır. Örnek: Adana - AD
  2. İsimleri iki kelimeden oluşan iller ilk iki harf yerine bu kelimelerin baş harlerini kullanabilir. Örnek: Kahramanmaraş - KM.
  3. İlk iki harfi başka illerle aynı olan illerden nüfusu en çok olan bu iki harfi kullanır. Örnek: Ankara - AN. Ankara nüfusu fazla olduğu için Antalya'dan öncelikli.
  4. Önceki 3 kural dışında kalan iller nüfus büyüklüğü sırasıyla baş harfleri ve il ismindeki kullanılmamış başka bir harfi seçer. Örnek: Antalya - AT. AN Ankara tarafından kullanılıyor.
  5. Geçerli bir sebep varsa istisna olarak yukarıdaki kuralların dışına çıkılabilir. Örnek: Trabzon - TZ. TR Türkiye uluslararası kodu ile karışabilir.
  6. Bu liste hazırlandıktan sonra il statüsü kazanan yerler yukarıdaki kurallara göre başka bir il tarafından kullanılmayan bir kısaltma seçerler.
  7. Kısaltmalar Türkiye dışında da kullanılacağı için Türkçe'ye özgü harfler (ÇĞIÖŞÜÂ) yerine ASCII karşılıkları (CGIOSUA) kullanılır. 
Kodlar kurallar sırasıyla uygulanarak aşağıdaki gibi seçildi.
Kural 1
Afyonkarahisar AF        Eskişehir      ES        Osmaniye       OS
Ağrı           AG        Gaziantep      GA        Rize           RI
Aksaray        AK        Giresun        GI        Tekirdağ       TE
Aydın          AY        Iğdır          IG        Tokat          TO
Bolu           BO        İstanbul       IS        Trabzon        TR
Çorum          CO        İzmir          IZ        Tunceli        TU
Denizli        DE        Kütahya        KU        Uşak           US
Diyarbakır     DI        Mersin         ME        Van            VA
Düzce          DU        Nevşehir       NE        Yalova         YA
Edirne         ED        Niğde          NI        Yozgat         YO
Elazığ         EL        Ordu           OR        Zonguldak      ZO

Kural 2
Bingöl         BG
Çanakkale      CK (Kural 1 tercih edilirse CA da olabilir.)
Diyarbakır     DB (Kural 1 tercih edilirse DI da olabilir.)
Gümüşhane      GH (Kural 1 tercih edilirse GU da olabilir.)
Kırıkkale      KK
Kahramanmaraş  KM
Kırklareli     KE (Kural 1 tercih edilirse KI da olabilir.)
Kırşehir       KS
Nevşehir       NS (Kural 1 tercih edilirse NE de olabilir.)
Şanlıurfa      SU
Tekirdağ       TD (Kural 1 tercih edilirse TE da olabilir.)

Kural 3
Adana          AD        Erzurum        ER        Muğla          MU
Ankara         AN        Hatay          HA        Samsun         SA
Balıkesir      BA        Kayseri        KA        Sivas          SI
Bitlis         BI        Konya          KO 
Bursa          BU        Manisa         MA 

Kural 4
Ardahan        AH        Çankırı        CN        Kastamonu      KT
Adıyaman       AI        Erzincan       EZ        Malatya        ML
Antalya        AT        Hakkâri        HK        Mardin         MR
Artvin *       AV        Isparta        IP        Muş            MS
Bilecik        BL        Karabük        KB        Sakarya        SK
Bartın         BN        Kocaeli        KC        Sinop          SP
Burdur         BR        Kilis          KL        Şırnak         SR
Batman         BT        Karaman        KN        Siirt          ST
Bayburt        BY        Kars           KR

* Artvin       AV (Kural 3 tercih edilirse AR de olabilir.)

Kural 5
Amasya         AA (İlk iki harf kaba bir kelime olarak algılanabilir.)
Trabzon        TZ (TR Türkiye'nin uluslararası kodu.)

Sunday, May 20, 2012

Hürriyet ve Zaman Gazeteleri İnternet Arşivleri

Gazetelerin arşivlerine internet üzerinden ulaşmak mümkün. Yazdığım script'le Hürriyet ve Zaman gazeteleri köşe yazılarını indirip UTF-8 Text'e çevirdim. Köşe yazılarının büyük kısmına kolay bir şekilde ulaşılabiliyor, fakat her iki gazetede de bazı köşe yazılarına ulaşılamıyor. Bazı günler ise tamamen kayıp.

- Gazetelerin 2001 yılı ve sonrası arşivlerine baktım.
- Yazıların teknik sebeplerle arşivde olmadığını umuyorum.
- Zaman Gazetesinde Ziya Perver'e ait yazıların büyük çoğunluğuna ulaşılamıyor.
- Her gün en az 7 köşe yazısı yayınlandığını varsaydım.

Arşivde bulunamayan tüm yazıların ve yazarların listesine ulaşmak için bana email gönderebilirsiniz.

Hürriyet Gazetesi arşivine http://hurarsiv.hurriyet.com.tr ve http://webarsiv.hurriyet.com.tr (2005/10/08 den önceki tarihler için) adreslerinden ulaşabilirsiniz.

Hürriyet internet arşivinden aşağıdaki tarihler yani 38 gün tamamen kayıp. Bu tarihler dışında 102 köşe yazısına daha ulaşılamıyor.

2001/01/22   2001/01/23   2001/02/27   2001/02/28   2001/04/14
2001/10/23   2001/10/24   2001/10/25   2001/10/26   2001/10/27
2001/10/28   2001/10/29   2001/10/30   2001/10/31   2001/11/01
2001/11/02   2001/11/03   2002/11/07   2002/12/21   2002/12/29
2003/01/22   2003/02/01   2003/02/02   2003/02/07   2003/02/11
2003/03/21   2003/03/31   2003/04/04   2003/04/05   2003/04/07
2003/04/12   2003/04/14   2005/04/23   2005/04/24   2005/10/08
2005/10/09   2005/10/10   2011/12/10




Zaman Gazetesi arşivine http://zaman.com.tr/arsiv.do adresinden ulaşılabilirsiniz.

Zaman internet arşivinden aşağıdaki tarihler yani 16 gün tamamen kayıp. Bu tarihler dışında 972 köşe yazısına daha ulaşılamıyor.

2001/01/21   2001/01/22   2001/09/21   2001/09/22  2001/12/30
2003/01/26   2003/01/27   2003/01/28   2003/01/29  2003/01/30
2003/01/31   2004/01/01   2004/01/02   2004/01/03  2004/01/06
2004/01/07

Saturday, May 12, 2012

Suffixes and Bigrams in Turkish

As I noted in my previous post, Turkish is an agglutinative language and makes heavy use of suffixes. Since suffixes are frequently used, top 2-grams (bigrams) will correspond to popular suffixes or to the end of one suffix and the beginning of the next.

Here is the list of top 25 2-grams and the suffixes they correspond to.

2-gram Frequency Suffix
ar     2.196%    -lar -ları -(ş)ar -arak
la     2.006%    -lar -ları -(y)la -laş
an     1.933%    -dan -(y)an
er     1.888%    -ler -leri -(ş)er -erek
in     1.734%    -(n)in -(i) -(i)niz -sin -siniz -cesine -(i)nci ...
le     1.727%    -ler -leri -(y)le -leş
de     1.539%    -de -den
en     1.350%    -den -(y)ken -(y)en
ın     1.336%    -(n)ın -(ı) -(ı)nız -sın -sınız -casına -(ı)ncı ...
da     1.304%    -da -dan
ya     1.188%    -(y)a -arak -(y)acak -(y)ama -(y)asi -(y)an
ir     1.179%    -dir -ttir
ma     1.174%    -ma -(y)ama -malı
bi     1.107%    
il     1.074%    
ka     1.021%    
ra     0.974%    -arak
ri     0.951%    
ak     0.949%    -mak -arak -(y)acak
nd     0.949%    
al     0.938%    -sal -malı
li     0.899%    -li -lik
di     0.860%    -dir -y(di) -di -dik
me     0.850%    -me -(y)eme -meli
or     0.815%    -(i)yor

Bigram frequencies in Turkish



This graph illustrates the frequency distribution of 2-grams (bigrams) in Turkish. The graph is composed of the top 500 2-grams. I have included the data for the top 100 2-grams below. Email me for a complete list.

Turkish is an agglutinative language and frequently uses suffixes. I expect the top 2-grams to correspond to the most frequently used suffixes. My expectation is confirmed by the data below. I will continue on this subject in another post.

Notes:
- Frequencies are computed from Hurriyet and Zaman newspapers using columnist articles between 2001 and 2011.

Data
Top 100 2-gram frequencies in Turkish
ar 2.196%    ni 0.764%    lı 0.564%    rd 0.419%
la 2.006%    ta 0.764%    ha 0.554%    ur 0.406%
an 1.933%    ek 0.741%    na 0.546%    ru 0.402%
er 1.888%    el 0.737%    bu 0.545%    iz 0.400%
in 1.734%    ay 0.733%    mi 0.544%    ği 0.386%
le 1.727%    et 0.712%    at 0.540%    ür 0.380%
de 1.539%    iy 0.707%    ad 0.525%    nu 0.380%
en 1.350%    ne 0.706%    im 0.514%    rl 0.375%
ın 1.336%    ol 0.701%    em 0.505%    ey 0.374%
da 1.304%    rı 0.686%    nl 0.499%    lm 0.372%
ya 1.188%    nı 0.684%    dı 0.494%    iş 0.360%
ir 1.179%    si 0.680%    es 0.480%    az 0.359%
ma 1.174%    yo 0.677%    ge 0.477%    ce 0.358%
bi 1.107%    ki 0.670%    on 0.476%    ık 0.350%
il 1.074%    te 0.664%    aş 0.472%    be 0.349%
ka 1.021%    am 0.650%    ik 0.467%    ul 0.338%
ra 0.974%    sa 0.640%    ıl 0.459%    rk 0.330%
ri 0.951%    ti 0.639%    ed 0.450%    ca 0.328%
ak 0.949%    ye 0.638%    tı 0.445%    st 0.321%
nd 0.949%    re 0.638%    se 0.436%    ld 0.319%
al 0.938%    as 0.632%    ün 0.435%    du 0.313%
li 0.899%    ba 0.628%    is 0.432%    lu 0.311%
di 0.860%    ve 0.594%    ke 0.430%    ğı 0.309%
me 0.850%    un 0.590%    kl 0.428%    gi 0.301%
or 0.815%    sı 0.579%    ır 0.424%    mı 0.301%

Friday, May 11, 2012

Frequencies of last letters in Turkish

Relative frequencies of last letters of words in Turkish.

 

 - 90% of the words in Turkish text end with only 11 of the letters in the alphabet.
- A large number of the letters in the alphabet are seen at the end of the words in small amounts (less than 1%).
- Frequencies are computed from Hurriyet and Zaman newspapers using columnist articles between 2001 and 2011.- The graph contains all letters with frequencies exceeding 0.001%.
- Note that letters w, x, q, and é are not part of the Turkish alphabet. They are used to write foreign words.

Data:

End of word letters in Turkish text.
Letter Frequency     Letter  Frequency
n      15.814%       h       0.324%
e      13.198%       f       0.313%
a      11.533%       d       0.237%
r      11.367%       o       0.217%
i      11.179%       b       0.141%
ı       7.690%       v       0.124%
k       6.714%       î       0.076%
u       4.092%       g       0.070%
m       3.624%       â       0.061%
z       2.716%       ğ       0.054%
l       2.515%       j       0.037%
t       2.179%       c       0.032%
ş       1.482%       w       0.025%
p       1.196%       x       0.025%
ü       1.075%       ö       0.003%
s       0.645%       û       0.001%
ç       0.625%       q       0.001%
y       0.612%       é       0.001%