2020-10-29 08:43:17 +00:00
|
|
|
|
import re
|
2017-11-02 15:32:24 +00:00
|
|
|
|
|
2020-10-29 08:43:17 +00:00
|
|
|
|
from ..punctuation import ALPHA_LOWER, ALPHA
|
2017-11-02 15:32:24 +00:00
|
|
|
|
from ...symbols import ORTH, NORM
|
2020-07-22 20:18:46 +00:00
|
|
|
|
|
2017-11-02 15:32:24 +00:00
|
|
|
|
|
2020-10-29 08:43:17 +00:00
|
|
|
|
_exc = {}
|
2017-11-02 15:32:24 +00:00
|
|
|
|
|
|
|
|
|
|
2020-10-29 08:43:17 +00:00
|
|
|
|
_abbr_period_exc = [
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "A.B.D.", NORM: "Amerika"},
|
|
|
|
|
{ORTH: "Alb.", NORM: "albay"},
|
|
|
|
|
{ORTH: "Ank.", NORM: "Ankara"},
|
|
|
|
|
{ORTH: "Ar.Gör."},
|
|
|
|
|
{ORTH: "Arş.Gör."},
|
|
|
|
|
{ORTH: "Asb.", NORM: "astsubay"},
|
|
|
|
|
{ORTH: "Astsb.", NORM: "astsubay"},
|
|
|
|
|
{ORTH: "As.İz."},
|
|
|
|
|
{ORTH: "as.iz."},
|
|
|
|
|
{ORTH: "Atğm", NORM: "asteğmen"},
|
|
|
|
|
{ORTH: "Av.", NORM: "avukat"},
|
|
|
|
|
{ORTH: "Apt.", NORM: "apartmanı"},
|
|
|
|
|
{ORTH: "apt.", NORM: "apartmanı"},
|
|
|
|
|
{ORTH: "Bçvş.", NORM: "başçavuş"},
|
|
|
|
|
{ORTH: "bçvş.", NORM: "başçavuş"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "bk.", NORM: "bakınız"},
|
|
|
|
|
{ORTH: "bknz.", NORM: "bakınız"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Bnb.", NORM: "binbaşı"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "bnb.", NORM: "binbaşı"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Böl.", NORM: "bölümü"},
|
|
|
|
|
{ORTH: "böl.", NORM: "bölümü"},
|
|
|
|
|
{ORTH: "Bşk.", NORM: "başkanlığı"},
|
|
|
|
|
{ORTH: "bşk.", NORM: "başkanlığı"},
|
|
|
|
|
{ORTH: "Bştbp.", NORM: "baştabip"},
|
|
|
|
|
{ORTH: "bştbp.", NORM: "baştabip"},
|
|
|
|
|
{ORTH: "Bul.", NORM: "bulvarı"},
|
|
|
|
|
{ORTH: "bul.", NORM: "bulvarı"},
|
|
|
|
|
{ORTH: "Cad.", NORM: "caddesi"},
|
|
|
|
|
{ORTH: "cad.", NORM: "caddesi"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "çev.", NORM: "çeviren"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Çvş.", NORM: "çavuş"},
|
|
|
|
|
{ORTH: "çvş.", NORM: "çavuş"},
|
2018-03-09 09:13:00 +00:00
|
|
|
|
{ORTH: "dak.", NORM: "dakika"},
|
|
|
|
|
{ORTH: "dk.", NORM: "dakika"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Doç.", NORM: "doçent"},
|
|
|
|
|
{ORTH: "doğ."},
|
|
|
|
|
{ORTH: "Dr.", NORM: "doktor"},
|
2021-01-05 02:41:53 +00:00
|
|
|
|
{ORTH: "dr.", NORM: "doktor"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "drl.", NORM: "derleyen"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Dz.", NORM: "deniz"},
|
|
|
|
|
{ORTH: "Dz.K.K.lığı"},
|
|
|
|
|
{ORTH: "Dz.Kuv."},
|
|
|
|
|
{ORTH: "Dz.Kuv.K."},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "dzl.", NORM: "düzenleyen"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Ecz.", NORM: "eczanesi"},
|
|
|
|
|
{ORTH: "ecz.", NORM: "eczanesi"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "ekon.", NORM: "ekonomi"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Fak.", NORM: "fakültesi"},
|
|
|
|
|
{ORTH: "Gn.", NORM: "genel"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "Gnkur.", NORM: "Genelkurmay"},
|
2018-03-09 09:13:00 +00:00
|
|
|
|
{ORTH: "Gn.Kur.", NORM: "Genelkurmay"},
|
|
|
|
|
{ORTH: "gr.", NORM: "gram"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Hst.", NORM: "hastanesi"},
|
|
|
|
|
{ORTH: "hst.", NORM: "hastanesi"},
|
|
|
|
|
{ORTH: "Hs.Uzm."},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "huk.", NORM: "hukuk"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Hv.", NORM: "hava"},
|
|
|
|
|
{ORTH: "Hv.K.K.lığı"},
|
|
|
|
|
{ORTH: "Hv.Kuv."},
|
|
|
|
|
{ORTH: "Hv.Kuv.K."},
|
|
|
|
|
{ORTH: "Hz.", NORM: "hazreti"},
|
|
|
|
|
{ORTH: "Hz.Öz."},
|
|
|
|
|
{ORTH: "İng.", NORM: "ingilizce"},
|
|
|
|
|
{ORTH: "İst.", NORM: "İstanbul"},
|
|
|
|
|
{ORTH: "Jeol.", NORM: "jeoloji"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "jeol.", NORM: "jeoloji"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Korg.", NORM: "korgeneral"},
|
|
|
|
|
{ORTH: "Kur.", NORM: "kurmay"},
|
|
|
|
|
{ORTH: "Kur.Bşk."},
|
|
|
|
|
{ORTH: "Kuv.", NORM: "kuvvetleri"},
|
|
|
|
|
{ORTH: "Ltd.", NORM: "limited"},
|
|
|
|
|
{ORTH: "ltd.", NORM: "limited"},
|
|
|
|
|
{ORTH: "Mah.", NORM: "mahallesi"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "mah.", NORM: "mahallesi"},
|
|
|
|
|
{ORTH: "max.", NORM: "maksimum"},
|
|
|
|
|
{ORTH: "min.", NORM: "minimum"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Müh.", NORM: "mühendisliği"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "müh.", NORM: "mühendisliği"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "M.Ö."},
|
|
|
|
|
{ORTH: "M.S."},
|
|
|
|
|
{ORTH: "Onb.", NORM: "onbaşı"},
|
|
|
|
|
{ORTH: "Ord.", NORM: "ordinaryüs"},
|
|
|
|
|
{ORTH: "Org.", NORM: "orgeneral"},
|
|
|
|
|
{ORTH: "Ped.", NORM: "pedagoji"},
|
|
|
|
|
{ORTH: "Prof.", NORM: "profesör"},
|
|
|
|
|
{ORTH: "prof.", NORM: "profesör"},
|
|
|
|
|
{ORTH: "Sb.", NORM: "subay"},
|
|
|
|
|
{ORTH: "Sn.", NORM: "sayın"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "sn.", NORM: "saniye"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Sok.", NORM: "sokak"},
|
|
|
|
|
{ORTH: "sok.", NORM: "sokak"},
|
|
|
|
|
{ORTH: "Şb.", NORM: "şube"},
|
|
|
|
|
{ORTH: "şb.", NORM: "şube"},
|
|
|
|
|
{ORTH: "Şti.", NORM: "şirketi"},
|
|
|
|
|
{ORTH: "şti.", NORM: "şirketi"},
|
|
|
|
|
{ORTH: "Tbp.", NORM: "tabip"},
|
|
|
|
|
{ORTH: "tbp.", NORM: "tabip"},
|
|
|
|
|
{ORTH: "T.C."},
|
|
|
|
|
{ORTH: "Tel.", NORM: "telefon"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "tel.", NORM: "telefon"},
|
|
|
|
|
{ORTH: "telg.", NORM: "telgraf"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Tğm.", NORM: "teğmen"},
|
2018-03-08 17:02:25 +00:00
|
|
|
|
{ORTH: "tğm.", NORM: "teğmen"},
|
|
|
|
|
{ORTH: "tic.", NORM: "ticaret"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Tug.", NORM: "tugay"},
|
|
|
|
|
{ORTH: "Tuğg.", NORM: "tuğgeneral"},
|
|
|
|
|
{ORTH: "Tümg.", NORM: "tümgeneral"},
|
|
|
|
|
{ORTH: "Uzm.", NORM: "uzman"},
|
|
|
|
|
{ORTH: "Üçvş.", NORM: "üstçavuş"},
|
|
|
|
|
{ORTH: "Üni.", NORM: "üniversitesi"},
|
2021-01-05 02:41:53 +00:00
|
|
|
|
{ORTH: "Ütğm.", NORM: "üsteğmen"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "vb."},
|
2018-03-09 09:13:00 +00:00
|
|
|
|
{ORTH: "vs.", NORM: "vesaire"},
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "Yard.", NORM: "yardımcı"},
|
|
|
|
|
{ORTH: "Yar.", NORM: "yardımcı"},
|
|
|
|
|
{ORTH: "Yd.Sb."},
|
|
|
|
|
{ORTH: "Yard.Doç."},
|
|
|
|
|
{ORTH: "Yar.Doç."},
|
|
|
|
|
{ORTH: "Yb.", NORM: "yarbay"},
|
|
|
|
|
{ORTH: "Yrd.", NORM: "yardımcı"},
|
|
|
|
|
{ORTH: "Yrd.Doç."},
|
|
|
|
|
{ORTH: "Y.Müh."},
|
|
|
|
|
{ORTH: "Y.Mim."},
|
|
|
|
|
{ORTH: "yy.", NORM: "yüzyıl"},
|
2020-10-29 08:43:17 +00:00
|
|
|
|
]
|
2017-11-02 15:32:24 +00:00
|
|
|
|
|
2020-10-29 08:43:17 +00:00
|
|
|
|
for abbr in _abbr_period_exc:
|
|
|
|
|
_exc[abbr[ORTH]] = [abbr]
|
2017-11-02 15:32:24 +00:00
|
|
|
|
|
2020-10-29 08:43:17 +00:00
|
|
|
|
_abbr_exc = [
|
2020-11-25 09:33:49 +00:00
|
|
|
|
{ORTH: "AB", NORM: "Avrupa Birliği"},
|
|
|
|
|
{ORTH: "ABD", NORM: "Amerika"},
|
|
|
|
|
{ORTH: "ABS", NORM: "fren"},
|
|
|
|
|
{ORTH: "AOÇ"},
|
|
|
|
|
{ORTH: "ASKİ"},
|
|
|
|
|
{ORTH: "Bağ-kur", NORM: "Bağkur"},
|
|
|
|
|
{ORTH: "BDDK"},
|
|
|
|
|
{ORTH: "BJK", NORM: "Beşiktaş"},
|
|
|
|
|
{ORTH: "ESA", NORM: "Avrupa uzay ajansı"},
|
|
|
|
|
{ORTH: "FB", NORM: "Fenerbahçe"},
|
|
|
|
|
{ORTH: "GATA"},
|
|
|
|
|
{ORTH: "GS", NORM: "Galatasaray"},
|
|
|
|
|
{ORTH: "İSKİ"},
|
|
|
|
|
{ORTH: "KBB"},
|
|
|
|
|
{ORTH: "RTÜK", NORM: "radyo ve televizyon üst kurulu"},
|
|
|
|
|
{ORTH: "TBMM"},
|
|
|
|
|
{ORTH: "TC"},
|
|
|
|
|
{ORTH: "TÜİK", NORM: "Türkiye istatistik kurumu"},
|
|
|
|
|
{ORTH: "YÖK"},
|
2020-10-29 08:43:17 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
for abbr in _abbr_exc:
|
|
|
|
|
_exc[abbr[ORTH]] = [abbr]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_num = r"[+-]?\d+([,.]\d+)*"
|
|
|
|
|
_ord_num = r"(\d+\.)"
|
|
|
|
|
_date = r"(((\d{1,2}[./-]){2})?(\d{4})|(\d{1,2}[./]\d{1,2}(\.)?))"
|
|
|
|
|
_dash_num = r"(([{al}\d]+/\d+)|(\d+/[{al}]))".format(al=ALPHA)
|
2021-01-05 02:41:53 +00:00
|
|
|
|
_roman_num = "M{0,3}(?:C[MD]|D?C{0,3})(?:X[CL]|L?X{0,3})(?:I[XV]|V?I{0,3})"
|
2020-10-29 08:43:17 +00:00
|
|
|
|
_roman_ord = r"({rn})\.".format(rn=_roman_num)
|
|
|
|
|
_time_exp = r"\d+(:\d+)*"
|
2017-11-02 15:32:24 +00:00
|
|
|
|
|
2020-10-29 08:43:17 +00:00
|
|
|
|
_inflections = r"'[{al}]+".format(al=ALPHA_LOWER)
|
|
|
|
|
_abbrev_inflected = r"[{a}]+\.'[{al}]+".format(a=ALPHA, al=ALPHA_LOWER)
|
2017-11-02 15:32:24 +00:00
|
|
|
|
|
2021-01-05 02:41:53 +00:00
|
|
|
|
_nums = r"(({d})|({dn})|({te})|({on})|({n})|({ro})|({rn}))({inf})?".format(
|
|
|
|
|
d=_date,
|
|
|
|
|
dn=_dash_num,
|
|
|
|
|
te=_time_exp,
|
|
|
|
|
on=_ord_num,
|
|
|
|
|
n=_num,
|
|
|
|
|
ro=_roman_ord,
|
|
|
|
|
rn=_roman_num,
|
|
|
|
|
inf=_inflections,
|
|
|
|
|
)
|
2017-11-02 15:32:24 +00:00
|
|
|
|
|
|
|
|
|
TOKENIZER_EXCEPTIONS = _exc
|
2021-01-05 02:41:53 +00:00
|
|
|
|
TOKEN_MATCH = re.compile(
|
|
|
|
|
r"^({abbr})|({n})$".format(n=_nums, abbr=_abbrev_inflected)
|
|
|
|
|
).match
|