zemberek-2.1.1/ 0000755 0001750 0001750 00000000000 11070734746 011770 5 ustar rail rail zemberek-2.1.1/surumler.txt 0000644 0001750 0001750 00000020422 11023736006 014374 0 ustar rail rail Surum Degisiklikler listesi
Surum 2.1
- Cesitli hata giderimi.
Surum 2.0 (11 subat 2007)
- Zemberek alt yapisi tamamen dilden bagimsiz hale getirildi. Kod buyuk oranda elden gecirildi.
- xml ek tnaimlama sitemi degisti.
- kok bulma metodu eklendi. (Stemmer)
- Buyuk oranda calisan Turkmence ve test amacli Azerice dilleri eklendi.
-----------------------------------------------
Surum 0.6.4 (29 Ocak 2006), OpenOffice.org eklentisi 1.0-Beta3
- Kok kullanim frekansi ile ilgili 0.6.3 surumundeki degisiklikteki bir hata duzeltildi. istatistik dosyasinin dagitim icinde yer almasi gerekmiyor.
- Sayilar icin oneri sistemi kullanilmaya calisilirsa ortaya cikan bir NPE hatasi giderildi
- Onceki surumlerde yer almayan bazi bilisim terimleri eklendi.
- Kod icinde bazi iyilestirmeler gerceklestirildi (hata bildirimi, kayit tutma ve dosya yukleme siniflarinda)
-----------------------------------------------
Surum 0.6.3 (27 Aralik 2005), OpenOffice.org eklentisi 1.0-Beta2
- Kok kullanim frekansina dayali basit puanlama mekanizmasi isler hale gecirildi. Ascii donusturucu ve oneri uretim islemleri bu sayede sonuclari daha uygun sekilde siraliyor.
- Oneri islemi kisaltma denetimi sirasinda NPE (Null Pointer Exception) hatasi verebiliyordu. Duzeltildi.
- Ascii->Turkce donusum islemi kucuk I harfi icin islemiyordu. Duzeltildi (Halen buyuk I harfi ile iliskili bir hata mevcut)
- Zemberek sinifina String[] cinsinden donus yapan Ascii Turkce donusturucu eklendi. Ayrica ayni sinifa Cozumleyici, oneri uretim siniflarina kolay erisim metotlari da eklendi.
- Gelistirme kodlarinda Dom4j kutuphanesine bagimlilik kaldirildi. Xml okuma islemleri icin Java'nin kendi ic siniflari kullaniliyor. - Ek tanimlama dosyasinin yapisi xml bilesen (element) ozellikleri (attribute) yerine dogrudan bilesen icerigini kullanacak sekilde degistirildi. Ornegin yerine ... seklinde.
------------------------------------------------
Surum 0.6.2, OpenOffice.org eklentisi 1.0-Beta
- Kisaltma destegi
- 500'e yakin eksik kok eklendi
- Cesitli ek dizilim hatalari giderildi.
- Ilk olusum suresinde bellek kullaniminda iyilestirme
Konular::
- Kisaltmalarin sisteme eklenmesi ile oneri sisteminin hizinda dusus gerceklesmis olabilir. Ancak bunun kullaniciya dogrudan yansimayacagini tahmin ediyoruz.
-------------------------------------
Surum 0.6.1
- Ozellikle Open Office eklentisi gibi uygulamalari ilk acilista fazla bekletmemek icin kaynak yukleme konusunda hiz arttirici bir kac calisma gerceklestirildi. Bu konuda daha fazla calisma yapilmasi gerekebilir.
--------------------------------------
Surum 0.6
- Yapi buyuk olcude dilden bagimsiz bir hale geldi. Yani farkli Turk dillerine iliskin islemler zemberek ile
daha kolay bicimde gerceklestirilebilecek. Yapiyi bagimsizlastirmak icin alt yapida ciddi
degisiklikler gerceklestirildi. Halen az da olsa degisiklik gerekiyor. Ilk farkli dil uygulamasi
olarak Turkmence uzerinde calisma yapilacak (Guychmyrat Amanmyradow onceki kod yapisi ile zaten Turkmece
konusunda calisma gerceklestirimisti).
- Ek yapisi degistirildi. Ekler artik ayri ayri sinif degil, dis bir dosyada tanimmlanip tek bir sinif ile ifade ediliyor.
Bu sayede Zemberek icindeki 120 civarindaki sinif silinmis oldu
- Oneri sistemi istatistiksel kok bilgilerini kullanip onerilerin daha uygun sekilde siralanmasini sagliyor.
- Kelime uretim mekanizmasi eklendi. Istenilen kok ve ek listesi ile kelime uretimi saglanabiliyor.
- Kelime ayrisim islemi eklendi. Ornegin "zembereklere" kelimesi "zemberek-ler-e" seklinde ayristiriliyor. Bunun
cozumlemeden farki eklerin icerigini ayristirmasi.
- Proje sinif ve dizin yapisinda cesitli degisiklikler gerceklestirildi. Gelisim amacli kodlarda ve test
kodlarinda Java 5 kullanilmaya baslandi.
- Zemberek erisim sinifindaki erisim metodlarinda degisiklik ve eklemeler meydana geldi. Zemberek sinifinin yapisi artik Singleton degil.
- Deneme amacli rasgele basit cumlecik olusturma sinifi eklendi.
- Oneri mekanizmasinda kullanilan benzerlik algoritmasinin basarimi arttirildi.(Alphan)
- Cozumleme islemi artik ayni koke ait ilk ek cozumunde islemi durdurmuyor, tum olasi ek cozumlerini buluyor.
- Rasgele siralanmis ekleri dil biglisine gore siraya dizen algoritma eklendi. Bu basir ceviri islemlerinde kullanilabilir.
- Bazi bilinen bilisim ozel isimleri kok olarak sisteme eklenmeye basladi.
Konular:
- Dil bagimsizligi ve ek degisiklikleri cozumleme dogruluk basarimini az da olsa kotu yonde etkilemis olabilir.
- eklerin dis dosyadan okunmasi ve islenmesi nedeniyle ilklendirme suresi biraz daha uzadi (200-500ms).
------------------------------------------
Surum 0.5.1
- Zemberek projesinin diger java projeleri uzerinden daha kolay kullanilmasini saglayan degisiklikler yapildi.
- Apache Commons-Logging'e olan bagimlilik kaldirildi. Java'nin kendi ic kayit tutma mekanizmasi kullaniliyor.
-------------------------------------------
Surum 0.5
- Kilavuz tamamlandi. yaklasik 23.500 kok ve 7000 ozel kisi adi ile otuz binden fazla kelime kokunu taniyabiliyor.
- < uzeri - uzer*leri >, < gozyasi - gozyas*lari> turundeki ozel durumlar gerceklendi..
- "imek" fiiline iliskin hatalar giderildi.
- Eklentinin kilitlenmesine neden olan kritik bir hata dahil pek cok irili ufakli hata giderildi.
- Sistemin ikili (binary) bir kilavuz dosyasi uzerinden calismasi saglandi.Kok agaci olusturma mekanizmasi duzenlendi. Bu sayede ilk calisma hizi biraz daha iyilestirildi
- Yazilim yapisinin farkli Turk lehceleri ile de calisabilmesi icin alt yapi calismasina baslandi.
- Ek olusum mekanizmasinin daha az kaynak tuketmesini saglayacak mekanizma icin calismaya baslandi.
- Ascii->Turkce donusumunde birden cok secenegin olustugu durumlarda dogru olan kelimenin secimini saglayacak puanlama melkanizmasinin ilk hali gerceklestirildi. Bu ozellik duzenlenip gelistirilerek bir sonraki surumde calistirilacak.
---------------------------------------------
Surum 0.4.1
- Ozel adlar eklendi
- Muhtelif sozluk, ek, cozumleyici ve ozel durum hatasi giderildi.
- Duzyazi sozluk okuyucu hizi arttirildi, ama sozlugun buyumesi ile bu artis hissedilmiyor.
- Kelime sayisi Ozel Adlarla birlikte 25bin civarina yukseldi.
------------------------------------------
Surum 0.4
- Proje isim ve paket yapisi degisti.
- Temizleyici mekanizma eklendi.
- Zemberek Open Office Eklenti projesinin ilk surumleri cikti.
-----------------------------------------
Surum 0.3
- Hatali kelimeler icin oneri mekanizmasi konusundaki ilk calisma gerceklestirildi. Denemek icin
giris alanina bir harfi eksik, fazla, yanlis ya da iki harfi yer degistirmis hatali bir kelime yazip "Oner" dugmesine basin.
- Cozumleme ve denetleme mekanizmasi yaklasik %99 kesinlikle calisiyor.
- Hatali olup dogru kabul edilen durumlarin bir kismi ortadan kaldirildi.
- Kod yapisi biraz daha duzeltildi.
----------------------------------------------------
Surum 0.2
- Arayuz yenilendi. giris ve cikis icin iki ayri alan bulunuyor. giris'e yazarak, kopyala-yapistir yontemi ile ya da doyadan okuyarak veri yerlestiriliyor.
- Islemler giris icindeki yazi uzerinden gerceklestiriliyor. Su islemler mevcut:
Denetleme: giris uzerinde kelime dogruluk testi yapiliyor. Sonucta hatali kelimerin basina "#" isareti koyuluyor. diger kelimelerde oynama yapilmiyor
Cozumleme: Bu tum kelimeri ayrintili icimde cozumluyor. kok ve ekleri , bir kelimenin tum olasi kokleri icin belirtiyor.
Ascii->Tr: Turkce karakter kullanmadan yazilmis yaziyi turkce yapmaya calisir. Sonucta basi kelimelerde birden fazla sonuc cikabilir.
Tr->Ascii: turkceye ozel karakterleri ingilizcede de olan benzerlerine donusturur.
Hecele: basit blok heceleme islemi.
Bazi konular:
Sistemdeki GUI demo amaclidir. Cozumleme ve diger islemlerde hatalar soz konusudur. Henuz cozumleyici basarimi %95 civarinda oldugundan cozulemeyen kelimeler ortaya cikabilir. Her yeni versiyonda basarim artacaktir. Yanlis kelimelerin dogru varsayildigi durumlar soz konusu olabilir. Bu konu da yeni versiyonlarda gelistirilecektir. Algoritmalar simdilik fonksiyonellik gozetilerek gelistirilmektedir. Bu asamada performans calismasini zararli buldugumuzdan sistem beklenenden yavas calisabilir, ya da fazla kaynak tuketebilir. Bu konudaki calismalar umuyoruz bir kac surum sonra gerceklestirilebilir.
--------------------------------------------------
Surum 0.1
Temel cozumleyici ve heceleyici zemberek-2.1.1/build.properties 0000644 0001750 0001750 00000000016 11070141602 015161 0 ustar rail rail surum = 2.1.1
zemberek-2.1.1/build.xml 0000644 0001750 0001750 00000036313 11057027540 013607 0 ustar rail rail
zemberek-2.1.1/lib/ 0000755 0001750 0001750 00000000000 11070734574 012535 5 ustar rail rail zemberek-2.1.1/lib/dagitim/ 0000755 0001750 0001750 00000000000 11070734574 014153 5 ustar rail rail zemberek-2.1.1/lib/gelistirme/ 0000755 0001750 0001750 00000000000 11070734574 014701 5 ustar rail rail zemberek-2.1.1/deney/ 0000755 0001750 0001750 00000000000 11070734570 013067 5 ustar rail rail zemberek-2.1.1/deney/net/ 0000755 0001750 0001750 00000000000 11070734570 013655 5 ustar rail rail zemberek-2.1.1/deney/net/zemberek/ 0000755 0001750 0001750 00000000000 11070734570 015461 5 ustar rail rail zemberek-2.1.1/deney/net/zemberek/yapi/ 0000755 0001750 0001750 00000000000 11070734570 016423 5 ustar rail rail zemberek-2.1.1/deney/net/zemberek/yapi/obek/ 0000755 0001750 0001750 00000000000 11070734570 017343 5 ustar rail rail zemberek-2.1.1/deney/net/zemberek/yapi/obek/EkKalipTipi.java 0000644 0001750 0001750 00000002045 10636110034 022343 0 ustar rail rail /*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is "Zemberek Dogal Dil Isleme Kutuphanesi"
*
* The Initial Developer of the Original Code is
* Ahmet A. Akin, Mehmet D. Akin.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK *****
*/
package net.zemberek.yapi.obek;
public enum EkKalipTipi {
YALIN,
KISI,
KISI_I,
KISI_A,
ISIM_I,
ISIM_A
}
zemberek-2.1.1/deney/net/zemberek/yapi/obek/BasitKelimeObegiBulucu.java 0000644 0001750 0001750 00000012440 11025714702 024521 0 ustar rail rail /*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is "Zemberek Dogal Dil Isleme Kutuphanesi"
*
* The Initial Developer of the Original Code is
* Ahmet A. Akin, Mehmet D. Akin.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK *****
*/
package net.zemberek.yapi.obek;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import net.zemberek.bilgi.KaynakYukleyici;
import net.zemberek.erisim.Zemberek;
import net.zemberek.islemler.KokBulucu;
import net.zemberek.tr.yapi.TurkiyeTurkcesi;
import net.zemberek.yapi.Kok;
public class BasitKelimeObegiBulucu {
private KelimeObekDeposu depo;
private KokBulucu kokBulucu;
public BasitKelimeObegiBulucu(KelimeObekDeposu depo, KokBulucu kokBulucu) {
this.depo = depo;
this.kokBulucu = kokBulucu;
}
/**
* bir dizi kok icerisindeki olasi kok obek dizilimlerini bir liste icerisinde dondurur.
* Ornegin "eli kalem tutan yardim etsin dort goz gozu gormeyince" cumlesindeki koklerin
* dizi halinde gonderildigini ve tum kelime obeklerinin dpeoda bulundugu var sayilirsa asagidaki
* kok obekleri doner:
* " el, kalem, tutmak"
* " yardim etmek "
* " dort, goz "
* " goz, goz, gormek "
* dikkat edilirse sistem tum olasi kok obeklerini buluyor, "dort goz" ya da "goz gozu gormemek" icin
* TODO: bu islem henuz efektif degil.
*
* @param kokler
* @return
*/
public List adayBul(Kok... kokler) {
List adaylar = new ArrayList();
for (int i = 0; i < kokler.length; i++) {
if (kokler.length > 1 && i <= kokler.length - 2)
for (int j = i + 1; j < kokler.length; j++) {
Kok[] testDizi = new Kok[j - i + 1];
System.arraycopy(kokler, i, testDizi, 0, j - i + 1);
KelimeObegi aday = obekOlustur(testDizi);
if (depo.var(aday))
adaylar.add(aday);
}
}
return adaylar;
}
private KelimeObegi obekOlustur(Kok... kokler) {
KelimeObekBileseni bilesenler[] = new KelimeObekBileseni[kokler.length];
for (int i = 0; i < kokler.length; i++)
bilesenler[i] = new KelimeObekBileseni(kokler[i], EkKalipTipi.YALIN);
return new KelimeObegi(bilesenler);
}
/**
* cumle kelimelerini cozumleyip kok adaylarindan ilklerini alarak buna dayanan
* kok dizisi ile kelime obklerini bulmaya calisir.
* Aslinda tum olasi kok kombinasyonlari ile denemesi gerekir.
*
* @param cumle
* @return
*/
public List adayBul(String cumle) {
List kokler = new ArrayList();
String[] strs = cumle.replaceAll(" \\t+", "").split("[\\| ]");
for (String str : strs) {
Kok[] adayKokler = kokBulucu.kokBul(str);
if (adayKokler.length > 1) {
// kok icerigi boyuna gore buyukten kucuge sirala.
Arrays.sort(adayKokler, new Comparator() {
public int compare(Kok o1, Kok o2) {
return o2.icerik().length() - o1.icerik().length();
}
});
}
if (adayKokler.length > 0)
kokler.add(adayKokler[0]);
}
return adayBul(kokler.toArray(new Kok[kokler.size()]));
}
public static void main(String[] args) throws IOException {
Zemberek zemberek = new Zemberek(new TurkiyeTurkcesi());
DuzyaziKelimeObegiOkuyucu o = new DuzyaziKelimeObegiOkuyucu(zemberek.kokBulucu());
List obekler = o.tumunuOku("deney/obekler.txt");
MapTabanliKelimeObekDeposu kod = new MapTabanliKelimeObekDeposu();
for (KelimeObegi obek : obekler) {
kod.ekle(obek);
}
BasitKelimeObegiBulucu bkob = new BasitKelimeObegiBulucu(kod, zemberek.kokBulucu());
BufferedReader reader = new KaynakYukleyici("utf-8").getReader("deney/test-cumleleri.txt");
while (reader.ready()) {
String[] cumller = reader.readLine().replaceAll("[-,]", "").split("[.]");
for (String cumle : cumller) {
if (cumle.length() < 5)
continue;
List adaylar = bkob.adayBul(cumle);
System.out.println("cumle = " + cumle);
System.out.println("adaylar = " + adaylar);
}
}
}
}
zemberek-2.1.1/deney/net/zemberek/yapi/obek/KelimeObegi.java 0000644 0001750 0001750 00000004164 11025714702 022362 0 ustar rail rail /*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is "Zemberek Dogal Dil Isleme Kutuphanesi"
*
* The Initial Developer of the Original Code is
* Ahmet A. Akin, Mehmet D. Akin.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK *****
*/
package net.zemberek.yapi.obek;
import java.util.Arrays;
public class KelimeObegi implements Kavram {
private final KelimeObekBileseni[] bilesenler;
public KelimeObegi(KelimeObekBileseni[] bilesenler) {
this.bilesenler = bilesenler;
}
public int kelimeSayisi() {
return bilesenler.length;
}
public KelimeObekBileseni[] bilesenler() {
return bilesenler;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
KelimeObegi that = (KelimeObegi) o;
if (bilesenler != null ? !Arrays.deepEquals(bilesenler, that.bilesenler) : that.bilesenler != null)
return false;
return true;
}
public int hashCode() {
return (bilesenler != null ? Arrays.deepHashCode(bilesenler) : 0);
}
@Override
public String toString() {
StringBuilder b = new StringBuilder();
for (int i = 0; i < bilesenler.length; i++) {
b.append(bilesenler[i].kok().icerik());
if (i < bilesenler.length - 1)
b.append("|");
}
return b.toString();
}
}
zemberek-2.1.1/deney/net/zemberek/yapi/obek/Kavram.java 0000644 0001750 0001750 00000001733 10636110034 021421 0 ustar rail rail /*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is "Zemberek Dogal Dil Isleme Kutuphanesi"
*
* The Initial Developer of the Original Code is
* Ahmet A. Akin, Mehmet D. Akin.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK *****
*/
package net.zemberek.yapi.obek;
public interface Kavram {
}
zemberek-2.1.1/deney/net/zemberek/yapi/obek/KelimeObekDeposu.java 0000644 0001750 0001750 00000001516 11025714702 023373 0 ustar rail rail package net.zemberek.yapi.obek;
import java.util.List;
import net.zemberek.yapi.Kok;
/**
* Farkli Kelime obek gerceklemeleri icin ortak arayuz.
*/
public interface KelimeObekDeposu {
/**
* depoya kelime obegi ekler.
* @param obek
* @return
*/
KelimeObekDeposu ekle(KelimeObegi obek);
/**
* depoya bir ya da birden fazla kelime obegi ekler.
* @param obekler
* @return
*/
KelimeObekDeposu ekle(KelimeObegi... obekler);
/**
* depodan istenen koklerin gectigi kelime obeklerinin listesini dondurur.
* @param kokler
* @return
*/
List obekAra(Kok... kokler);
/**
* bir kelime obeginin depoda olup olmadigini dondurur
* @param obek
* @return
*/
boolean var(KelimeObegi obek);
}
zemberek-2.1.1/deney/net/zemberek/yapi/obek/KokObegi.java 0000644 0001750 0001750 00000003100 11025714702 021665 0 ustar rail rail /*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is "Zemberek Dogal Dil Isleme Kutuphanesi"
*
* The Initial Developer of the Original Code is
* Ahmet A. Akin, Mehmet D. Akin.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK *****
*/
package net.zemberek.yapi.obek;
import java.util.Arrays;
import net.zemberek.yapi.Kok;
public class KokObegi {
public final Kok[] kokler;
public KokObegi(Kok[] kokler) {
this.kokler = kokler;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
KokObegi that = (KokObegi) o;
return Arrays.equals(kokler, that.kokler);
}
public int hashCode() {
return (kokler != null ? Arrays.hashCode(kokler) : 0);
}
@Override
public String toString() {
return Arrays.toString(kokler);
}
}
zemberek-2.1.1/deney/net/zemberek/yapi/obek/KelimeObekBileseni.java 0000644 0001750 0001750 00000003661 10636110034 023664 0 ustar rail rail /*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is "Zemberek Dogal Dil Isleme Kutuphanesi"
*
* The Initial Developer of the Original Code is
* Ahmet A. Akin, Mehmet D. Akin.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK *****
*/
package net.zemberek.yapi.obek;
import net.zemberek.yapi.Kok;
public class KelimeObekBileseni {
final Kok kok;
final EkKalipTipi ekKalipTipi;
public KelimeObekBileseni(Kok kok, EkKalipTipi ekKalipTipi) {
this.kok = kok;
this.ekKalipTipi = ekKalipTipi;
}
public Kok kok() {
return kok;
}
public EkKalipTipi ekKalipTipi(){
return ekKalipTipi;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
KelimeObekBileseni that = (KelimeObekBileseni) o;
if (ekKalipTipi != that.ekKalipTipi) return false;
if (kok != null ? !kok.equals(that.kok) : that.kok != null) return false;
return true;
}
public int hashCode() {
int result;
result = (kok != null ? kok.hashCode() : 0);
result = 31 * result + (ekKalipTipi != null ? ekKalipTipi.hashCode() : 0);
return result;
}
}
zemberek-2.1.1/deney/net/zemberek/yapi/obek/MapTabanliKelimeObekDeposu.java 0000644 0001750 0001750 00000007346 11025714702 025333 0 ustar rail rail /*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is "Zemberek Dogal Dil Isleme Kutuphanesi"
*
* The Initial Developer of the Original Code is
* Ahmet A. Akin, Mehmet D. Akin.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK *****
*/
package net.zemberek.yapi.obek;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.zemberek.yapi.Kok;
public class MapTabanliKelimeObekDeposu implements KelimeObekDeposu {
private Map> kokObekKumeTablosu = new HashMap>();
private Set obekler = new HashSet();
public KelimeObekDeposu ekle(KelimeObegi obek) {
if (obek == null)
throw new NullPointerException("null eklenemez..");
obekler.add(obek);
for (KelimeObekBileseni obekBileseni : obek.bilesenler()) {
if (kokObekKumeTablosu.containsKey(obekBileseni.kok)) {
kokObekKumeTablosu.get(obekBileseni.kok).add(obek);
} else {
Set s = new HashSet(2);
s.add(obek);
kokObekKumeTablosu.put(obekBileseni.kok, s);
}
}
return this;
}
public KelimeObekDeposu ekle(KelimeObegi... obekler) {
if (obekler == null)
throw new NullPointerException("null eklenemez..");
for (KelimeObegi obek : obekler)
ekle(obek);
return this;
}
public List obekAra(Kok... kokler) {
Set> setset = new HashSet>(kokler.length);
for (Kok word : kokler) {
Set set = kokObekKumeTablosu.get(word);
if (set == null)
return Collections.emptyList();
else
setset.add(set);
}
if (setset.size() == 1)
return new ArrayList(setset.iterator().next());
Set min = Collections.min(setset, setBoyKiyaslayici );
setset.remove(min);
Set resultSet = new HashSet(min.size());
for (KelimeObegi phrase : min) {
for (Set set : setset) {
if (!set.contains(phrase))
break;
else
resultSet.add(phrase);
}
}
return new ArrayList(resultSet);
}
private final SetBoyKiyaslayici setBoyKiyaslayici = new SetBoyKiyaslayici();
class SetBoyKiyaslayici implements Comparator {
public int compare(Set o1, Set o2) {
if (o1 == null && o2 == null) return -0;
if (o1 == null) return 1;
if (o2 == null) return -1;
return o1.size() - o2.size();
}
}
public boolean var(KelimeObegi aday) {
return obekler.contains(aday);
}
}
zemberek-2.1.1/deney/net/zemberek/yapi/obek/DuzyaziKelimeObegiOkuyucu.java 0000644 0001750 0001750 00000011517 11025714702 025327 0 ustar rail rail package net.zemberek.yapi.obek;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import net.zemberek.bilgi.KaynakYukleyici;
import net.zemberek.bilgi.kokler.KokAdayiBulucu;
import net.zemberek.islemler.KelimeTabanliKokBulucu;
import net.zemberek.islemler.KokBulucu;
import net.zemberek.islemler.cozumleme.KelimeCozumleyici;
import net.zemberek.islemler.cozumleme.KesinHDKiyaslayici;
import net.zemberek.islemler.cozumleme.StandartCozumleyici;
import net.zemberek.tr.yapi.TurkiyeTurkcesi;
import net.zemberek.yapi.DilBilgisi;
import net.zemberek.yapi.Kok;
import net.zemberek.yapi.TurkceDilBilgisi;
public class DuzyaziKelimeObegiOkuyucu {
KokBulucu kokBulucu;
public DuzyaziKelimeObegiOkuyucu(KokBulucu kokBulucu) {
this.kokBulucu = kokBulucu;
}
public List tumunuOku(String kaynak) throws IOException {
BufferedReader reader = new KaynakYukleyici("utf-8").getReader(kaynak);
List koList = new ArrayList();
while (reader.ready()) {
String s = reader.readLine().trim();
if (s.startsWith("#"))
continue;
String kelimeDizi[] = s.replaceAll(" \\t+", "").split("[\\| ]");
// en az iki kok bulunmasi gerekir.
if (s.length() < 2)
continue;
List bilesenList = new ArrayList();
kelimeDizi = parantezKontrol(kelimeDizi);
// kok adaylarini bul. normalde kok tip bilgisi yer alsa daha iyi.
for (int i = 0; i < kelimeDizi.length; i++) {
Kok[] kokAdaylari = kokBulucu.kokBul(kelimeDizi[i]);
if (kokAdaylari.length == 0)
continue;
Kok aday = kokAdaylari[0];
if (kokAdaylari.length > 1) {
// kok icerigi boyuna gore buyukten kucuge sirala.
Arrays.sort(kokAdaylari, new Comparator() {
public int compare(Kok o1, Kok o2) {
return o2.icerik().length() - o1.icerik().length();
}
});
// son kok ise fiili yoksa fiil olmayan koku tercih et.
/* for (Kok kok : kokAdaylari) {
if (i == kelimeDizi.length - 1 && kok.tip() == FIIL) {
aday = kok;
break;
}
if (i < kelimeDizi.length - 1 && kok.tip() != FIIL) {
aday = kok;
break;
}
}*/
}
if (kokAdaylari.length > 0) {
KelimeObekBileseni bilesen = new KelimeObekBileseni(aday, EkKalipTipi.YALIN);
bilesenList.add(bilesen);
}
}
if (bilesenList.size() > 1)
koList.add(new KelimeObegi(bilesenList.toArray(new KelimeObekBileseni[bilesenList.size()])));
}
return koList;
}
/**
* dandik sekilde parantez icindeki kelimeleri eliyoruz.
*
* @param strs
* @return
*/
private String[] parantezKontrol(String[] strs) {
List news = new ArrayList();
boolean parantezIci = false;
for (String str : strs) {
if (str.length() == 0)
continue;
if (str.startsWith("(") && str.endsWith(")"))
continue;
if ("(".equals(str) || str.startsWith("("))
parantezIci = true;
if (")".equals(str) || str.endsWith(")"))
parantezIci = false;
if (!parantezIci) {
news.add(str);
}
}
return news.toArray(new String[news.size()]);
}
public static void main(String[] args) throws IOException {
DilBilgisi db = new TurkceDilBilgisi(new TurkiyeTurkcesi());
KokAdayiBulucu kokAdayiBulucu = db.kokler().kokBulucuFactory().kesinKokBulucu();
KelimeCozumleyici cozumleyici = new StandartCozumleyici(
kokAdayiBulucu,
new KesinHDKiyaslayici(),
db.alfabe(),
db.ekler(),
db.cozumlemeYardimcisi());
KokBulucu kokBulucu = new KelimeTabanliKokBulucu(cozumleyici, db.alfabe());
DuzyaziKelimeObegiOkuyucu o = new DuzyaziKelimeObegiOkuyucu(kokBulucu);
List obekler = o.tumunuOku("kelime-obekleri.txt");
for (KelimeObegi obek : obekler) {
System.out.println(obek);
}
}
}
zemberek-2.1.1/deney/net/zemberek/deney/ 0000755 0001750 0001750 00000000000 11070734570 016565 5 ustar rail rail zemberek-2.1.1/deney/net/zemberek/deney/DenetlemeHatasi.java 0000644 0001750 0001750 00000001002 10567720324 022457 0 ustar rail rail package net.zemberek.deney;
public class DenetlemeHatasi {
private String hatalikelime;
private int hataPozisyonu;
private String[] oneriler;
public DenetlemeHatasi(int hataPozisyonu, String hatalikelime, String[] oneriler) {
this.hatalikelime = hatalikelime;
this.hataPozisyonu = hataPozisyonu;
this.oneriler = oneriler;
}
public String getHatalikelime() {
return hatalikelime;
}
public int getHataPozisyonu() {
return hataPozisyonu;
}
public String[] getOneriler() {
return oneriler;
}
}
zemberek-2.1.1/deney/net/zemberek/deney/TestZemberekFactory.java 0000644 0001750 0001750 00000002437 10636745230 023374 0 ustar rail rail /*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is "Zemberek Dogal Dil Isleme Kutuphanesi"
*
* The Initial Developer of the Original Code is
* Serkan Kaba.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK *****
*/
package net.zemberek.deney;
import junit.framework.TestCase;
public class TestZemberekFactory extends TestCase {
public void testGetZemberek() {
//Aynı referansı döndürmesi gerekiyor ondan == ile kontrol ettim
assertTrue(ZemberekFactory.getZemberek("tr")==ZemberekFactory.getZemberek("tr"));
assertTrue(ZemberekFactory.getZemberek("tk")==ZemberekFactory.getZemberek("tk"));
}
}
zemberek-2.1.1/deney/net/zemberek/deney/MetinAraclari2.java 0000644 0001750 0001750 00000013541 11024147420 022220 0 ustar rail rail /*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is "Zemberek Dogal Dil Isleme Kutuphanesi"
*
* The Initial Developer of the Original Code is
* Ahmet A. Akin, Mehmet D. Akin.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK *****
*/
package net.zemberek.deney;
import java.util.ArrayList;
import java.util.List;
public class MetinAraclari2 {
private static int duzeltmeMesafesi(String s, String t, int limit)
{
int n = s.length(); //length of s
int m = t.length(); //length of t
int[][] d = new int[n + 1][m + 1]; // matrix
int cost; // cost
// Step 1
if (n == 0) return m;
if (m == 0) return n;
// Step 2
for (int i = 0; i <= n; d[i][0] = i++) ;
for (int j = 0; j <= m; d[0][j] = j++) ;
// Step 3
for (int i = 1; i <= n; i++)
{
//Step 4
for (int j = 1; j <= m; j++)
{
// Step 5
cost = (t.charAt(j-1) == s.charAt(i-1) ? 0 : 1);
// Step 6
d[i][j] = Math.min(Math.min(d[i-1][j] + 1, d[i][j-1] + 1), d[i-1][j-1] + cost);
// Step 6A
if (i > 1 && j > 1)
{
int trans = d[i-2][j-2] + 1;
if (s.charAt(i-2) != t.charAt(j-1)) trans++;
if (s.charAt(i-1) != t.charAt(j-2)) trans++;
if (d[i][j] > trans) d[i][j] = trans;
}
}
}
// Step 7
return d[n][m] > limit ? limit + 1 : d[n][m];
}
public static boolean duzeltmeMesafesiIcinde(String source, String target, int dist)
{
return (duzeltmeMesafesi(source, target, dist) <= dist);
}
public static boolean ParcasiDuzeltmeMesafesiIcinde(String s1, String s2, int distance)
{
if (s2.length() < (s1.length() - distance))
return false;
if (s2.length() >= s1.length())
{
String test = s2.substring(0, s1.length());
if (duzeltmeMesafesiIcinde(s1, test, distance)) return true;
test = s2.substring(0, s1.length() - 1);
if (duzeltmeMesafesiIcinde(s1, test, distance)) return true;
if (s2.length() >= s1.length() + 1)
{
test = s2.substring(0, s1.length() + 1);
if (duzeltmeMesafesiIcinde(s1, test, distance)) return true;
}
}
else
{
if (duzeltmeMesafesiIcinde(s1, s2, distance)) return true;
}
return false;
}
public static List adaylariBul(String s, char[] alfabe){
List adaylar = new ArrayList(20);
// Tek harf Eksik olanları bul
for(int i=0; i< s.length(); i++){
adaylar.add( s.substring(0 ,i) + s.substring(i+1) );
}
// Degisiklikleri ve eklemeleri bul
for(char c : alfabe){
for(int i=0; i< s.length(); i++){
adaylar.add( s.substring(0 ,i) + c + s.substring(i+1) );
}
for(int i=0; i< s.length(); i++){
adaylar.add( s.substring(0 ,i) + c + s.substring(i) );
}
}
// Transpozisyonları bul
for(int i=0; i< s.length()-1; i++){
adaylar.add( s.substring(0 ,i) + s.charAt(i+1) + s.charAt(i) + s.substring(i+2) );
}
return adaylar;
}
//
// ///
// /// Degistirilmis Levenshtein Edit Dist. algoritması. transpozisyonları da 1 düzeltme mesafesi olarak hesaplar.
// ///
// ///
// ///
// /// iki kelime arasindaki mesafe, tamsayi cinsinden. kucuk rakamlar daha buyuk benzerligi gosterir
public static int duzeltmeMesafesi(String source, String target)
{
int maxDif = Math.max(source.length(), target.length());
return duzeltmeMesafesi(source, target, maxDif);
}
public static void main(String[] args) {
List adaylar = adaylariBul("merhaba", "abcdefghijklmnoprstuvyz".toCharArray());
System.out.println("Adaylar (" + adaylar.size() + ") :" + adaylar);
// boolean s = ParcasiDuzeltmeMesafesiIcinde("ebm", "elma", 1);
// if (s) System.out.println("ok");
// int iter = 100000;
// TimeTracker.startClock("l1");
// for(int i=0; i