2016-12-24 02:21:00 +03:00
|
|
|
# encoding: utf8
|
2016-12-21 00:28:20 +03:00
|
|
|
from __future__ import unicode_literals
|
2016-12-08 14:06:36 +03:00
|
|
|
|
2017-01-14 17:51:59 +03:00
|
|
|
import re
|
|
|
|
|
|
|
|
from spacy.language_data.punctuation import ALPHA_LOWER, CURRENCY
|
2017-01-14 17:56:41 +03:00
|
|
|
from ..language_data.tokenizer_exceptions import _URL_PATTERN
|
2017-01-14 17:51:59 +03:00
|
|
|
|
2016-12-21 00:28:20 +03:00
|
|
|
ABBREVIATIONS = """
|
|
|
|
AkH.
|
|
|
|
Aö.
|
|
|
|
B.CS.
|
|
|
|
B.S.
|
|
|
|
B.Sc.
|
|
|
|
B.ú.é.k.
|
|
|
|
BE.
|
|
|
|
BEK.
|
|
|
|
BSC.
|
|
|
|
BSc.
|
|
|
|
BTK.
|
|
|
|
Be.
|
|
|
|
Bek.
|
|
|
|
Bfok.
|
|
|
|
Bk.
|
|
|
|
Bp.
|
|
|
|
Btk.
|
|
|
|
Btke.
|
|
|
|
Btét.
|
|
|
|
CSC.
|
|
|
|
Cal.
|
|
|
|
Co.
|
|
|
|
Colo.
|
|
|
|
Comp.
|
|
|
|
Copr.
|
|
|
|
Cs.
|
|
|
|
Csc.
|
|
|
|
Csop.
|
|
|
|
Ctv.
|
|
|
|
D.
|
|
|
|
DR.
|
|
|
|
Dipl.
|
|
|
|
Dr.
|
|
|
|
Dsz.
|
|
|
|
Dzs.
|
|
|
|
Fla.
|
|
|
|
Főszerk.
|
|
|
|
GM.
|
|
|
|
Gy.
|
|
|
|
HKsz.
|
|
|
|
Hmvh.
|
|
|
|
Inform.
|
|
|
|
K.m.f.
|
|
|
|
KER.
|
|
|
|
KFT.
|
|
|
|
KRT.
|
|
|
|
Ker.
|
|
|
|
Kft.
|
|
|
|
Kong.
|
|
|
|
Korm.
|
|
|
|
Kr.
|
|
|
|
Kr.e.
|
|
|
|
Kr.u.
|
|
|
|
Krt.
|
|
|
|
M.A.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|
|
|
an.
|
2016-12-08 14:06:36 +03:00
|
|
|
ang.
|
|
|
|
arch.
|
|
|
|
at.
|
|
|
|
aug.
|
2016-12-21 00:28:20 +03:00
|
|
|
b.a.
|
|
|
|
b.s.
|
|
|
|
b.sc.
|
2016-12-08 14:06:36 +03:00
|
|
|
bek.
|
|
|
|
belker.
|
|
|
|
berend.
|
|
|
|
biz.
|
|
|
|
bizt.
|
|
|
|
bo.
|
2016-12-21 00:28:20 +03:00
|
|
|
bp.
|
2016-12-08 14:06:36 +03:00
|
|
|
br.
|
2016-12-21 00:28:20 +03:00
|
|
|
bsc.
|
2016-12-08 14:06:36 +03:00
|
|
|
bt.
|
2016-12-21 00:28:20 +03:00
|
|
|
btk.
|
|
|
|
ca.
|
2016-12-08 14:06:36 +03:00
|
|
|
cc.
|
|
|
|
cca.
|
|
|
|
cf.
|
|
|
|
cif.
|
2016-12-21 00:28:20 +03:00
|
|
|
co.
|
|
|
|
corp.
|
|
|
|
cos.
|
2016-12-08 14:06:36 +03:00
|
|
|
cs.
|
2016-12-21 00:28:20 +03:00
|
|
|
csc.
|
2016-12-08 14:06:36 +03:00
|
|
|
csüt.
|
2016-12-21 00:28:20 +03:00
|
|
|
cső.
|
|
|
|
ctv.
|
2016-12-08 14:06:36 +03:00
|
|
|
dbj.
|
|
|
|
dd.
|
|
|
|
ddr.
|
|
|
|
de.
|
|
|
|
dec.
|
|
|
|
dikt.
|
|
|
|
dipl.
|
2016-12-21 00:28:20 +03:00
|
|
|
dj.
|
2016-12-08 14:06:36 +03:00
|
|
|
dk.
|
|
|
|
dny.
|
|
|
|
dolg.
|
|
|
|
dr.
|
|
|
|
du.
|
2016-12-21 00:28:20 +03:00
|
|
|
dzs.
|
2016-12-08 14:06:36 +03:00
|
|
|
ea.
|
|
|
|
ed.
|
|
|
|
eff.
|
|
|
|
egyh.
|
|
|
|
ell.
|
|
|
|
elv.
|
|
|
|
elvt.
|
|
|
|
em.
|
|
|
|
eng.
|
|
|
|
eny.
|
|
|
|
et.
|
|
|
|
etc.
|
|
|
|
ev.
|
|
|
|
ezr.
|
2016-12-21 00:28:20 +03:00
|
|
|
eü.
|
|
|
|
f.h.
|
2016-12-08 14:06:36 +03:00
|
|
|
f.é.
|
2016-12-21 00:28:20 +03:00
|
|
|
fam.
|
2016-12-08 14:06:36 +03:00
|
|
|
febr.
|
2016-12-21 00:28:20 +03:00
|
|
|
fej.
|
2016-12-08 14:06:36 +03:00
|
|
|
felv.
|
2016-12-21 00:28:20 +03:00
|
|
|
felügy.
|
2016-12-08 14:06:36 +03:00
|
|
|
ff.
|
|
|
|
ffi.
|
|
|
|
fhdgy.
|
|
|
|
fil.
|
|
|
|
fiz.
|
|
|
|
fm.
|
|
|
|
foglalk.
|
|
|
|
ford.
|
|
|
|
fp.
|
|
|
|
fr.
|
|
|
|
frsz.
|
|
|
|
fszla.
|
|
|
|
fszt.
|
|
|
|
ft.
|
|
|
|
fuv.
|
2016-12-21 00:28:20 +03:00
|
|
|
főig.
|
|
|
|
főisk.
|
|
|
|
főtörm.
|
|
|
|
főv.
|
2016-12-08 14:06:36 +03:00
|
|
|
gazd.
|
|
|
|
gimn.
|
|
|
|
gk.
|
|
|
|
gkv.
|
|
|
|
gondn.
|
2017-01-14 17:51:59 +03:00
|
|
|
Gr.
|
2016-12-08 14:06:36 +03:00
|
|
|
gr.
|
|
|
|
grav.
|
|
|
|
gy.
|
|
|
|
gyak.
|
|
|
|
gyártm.
|
2016-12-21 00:28:20 +03:00
|
|
|
gör.
|
2016-12-08 14:06:36 +03:00
|
|
|
hads.
|
|
|
|
hallg.
|
|
|
|
hdm.
|
|
|
|
hdp.
|
|
|
|
hds.
|
|
|
|
hg.
|
|
|
|
hiv.
|
|
|
|
hk.
|
|
|
|
hm.
|
|
|
|
ho.
|
|
|
|
honv.
|
|
|
|
hp.
|
|
|
|
hr.
|
|
|
|
hrsz.
|
|
|
|
hsz.
|
|
|
|
ht.
|
|
|
|
htb.
|
|
|
|
hv.
|
2016-12-21 00:28:20 +03:00
|
|
|
hőm.
|
2017-01-14 17:51:59 +03:00
|
|
|
ie.
|
2016-12-08 14:06:36 +03:00
|
|
|
i.e.
|
2016-12-21 00:28:20 +03:00
|
|
|
i.sz.
|
|
|
|
id.
|
2016-12-08 14:06:36 +03:00
|
|
|
ifj.
|
|
|
|
ig.
|
|
|
|
igh.
|
|
|
|
ill.
|
|
|
|
imp.
|
2016-12-21 00:28:20 +03:00
|
|
|
inc.
|
2016-12-08 14:06:36 +03:00
|
|
|
ind.
|
2016-12-21 00:28:20 +03:00
|
|
|
inform.
|
2016-12-08 14:06:36 +03:00
|
|
|
inic.
|
|
|
|
int.
|
|
|
|
io.
|
|
|
|
ip.
|
|
|
|
ir.
|
|
|
|
irod.
|
|
|
|
isk.
|
|
|
|
ism.
|
|
|
|
izr.
|
2016-12-21 00:28:20 +03:00
|
|
|
iá.
|
2016-12-08 14:06:36 +03:00
|
|
|
jan.
|
|
|
|
jav.
|
|
|
|
jegyz.
|
|
|
|
jjv.
|
|
|
|
jkv.
|
|
|
|
jogh.
|
|
|
|
jogt.
|
|
|
|
jr.
|
2016-12-21 00:28:20 +03:00
|
|
|
jvb.
|
2016-12-08 14:06:36 +03:00
|
|
|
júl.
|
|
|
|
jún.
|
|
|
|
karb.
|
|
|
|
kat.
|
2017-01-14 17:51:59 +03:00
|
|
|
kath.
|
2016-12-08 14:06:36 +03:00
|
|
|
kb.
|
|
|
|
kcs.
|
|
|
|
kd.
|
|
|
|
ker.
|
|
|
|
kf.
|
|
|
|
kft.
|
|
|
|
kht.
|
|
|
|
kir.
|
|
|
|
kirend.
|
|
|
|
kisip.
|
|
|
|
kiv.
|
|
|
|
kk.
|
|
|
|
kkt.
|
|
|
|
klin.
|
2016-12-21 00:28:20 +03:00
|
|
|
kp.
|
2017-01-14 17:51:59 +03:00
|
|
|
Kr.
|
2016-12-21 00:28:20 +03:00
|
|
|
krt.
|
|
|
|
kt.
|
|
|
|
ktsg.
|
|
|
|
kult.
|
|
|
|
kv.
|
|
|
|
kve.
|
|
|
|
képv.
|
|
|
|
kísérl.
|
2016-12-08 14:06:36 +03:00
|
|
|
kóth.
|
|
|
|
könyvt.
|
|
|
|
körz.
|
|
|
|
köv.
|
|
|
|
közj.
|
|
|
|
közl.
|
|
|
|
közp.
|
|
|
|
közt.
|
|
|
|
kü.
|
|
|
|
lat.
|
|
|
|
ld.
|
|
|
|
legs.
|
|
|
|
lg.
|
|
|
|
lgv.
|
|
|
|
loc.
|
|
|
|
lt.
|
2016-12-21 00:28:20 +03:00
|
|
|
ltd.
|
2016-12-08 14:06:36 +03:00
|
|
|
ltp.
|
|
|
|
luth.
|
2016-12-21 00:28:20 +03:00
|
|
|
m.a.
|
|
|
|
m.s.
|
|
|
|
m.sc.
|
|
|
|
ma.
|
2016-12-08 14:06:36 +03:00
|
|
|
mat.
|
|
|
|
mb.
|
|
|
|
med.
|
|
|
|
megh.
|
|
|
|
met.
|
|
|
|
mf.
|
|
|
|
mfszt.
|
2016-12-21 00:28:20 +03:00
|
|
|
min.
|
2016-12-08 14:06:36 +03:00
|
|
|
miss.
|
|
|
|
mjr.
|
|
|
|
mjv.
|
|
|
|
mk.
|
2016-12-21 00:28:20 +03:00
|
|
|
mlle.
|
|
|
|
mme.
|
2016-12-08 14:06:36 +03:00
|
|
|
mn.
|
|
|
|
mozg.
|
2016-12-21 00:28:20 +03:00
|
|
|
mr.
|
|
|
|
mrs.
|
|
|
|
ms.
|
|
|
|
msc.
|
|
|
|
má.
|
|
|
|
máj.
|
|
|
|
márc.
|
|
|
|
mé.
|
|
|
|
mélt.
|
2016-12-08 14:06:36 +03:00
|
|
|
mü.
|
|
|
|
műh.
|
|
|
|
műsz.
|
|
|
|
műv.
|
|
|
|
művez.
|
|
|
|
nagyker.
|
|
|
|
nagys.
|
2016-12-21 00:28:20 +03:00
|
|
|
nat.
|
|
|
|
nb.
|
2016-12-08 14:06:36 +03:00
|
|
|
neg.
|
|
|
|
nk.
|
|
|
|
nov.
|
|
|
|
nu.
|
|
|
|
ny.
|
|
|
|
nyilv.
|
2017-01-14 17:51:59 +03:00
|
|
|
Nyrt.
|
2016-12-21 00:28:20 +03:00
|
|
|
nyrt.
|
2016-12-08 14:06:36 +03:00
|
|
|
nyug.
|
|
|
|
obj.
|
|
|
|
okl.
|
|
|
|
okt.
|
|
|
|
olv.
|
|
|
|
orsz.
|
|
|
|
ort.
|
|
|
|
ov.
|
|
|
|
ovh.
|
|
|
|
pf.
|
|
|
|
pg.
|
2016-12-21 00:28:20 +03:00
|
|
|
ph.d
|
|
|
|
ph.d.
|
|
|
|
phd.
|
2016-12-08 14:06:36 +03:00
|
|
|
pk.
|
|
|
|
pl.
|
|
|
|
plb.
|
2016-12-21 00:28:20 +03:00
|
|
|
plc.
|
2016-12-08 14:06:36 +03:00
|
|
|
pld.
|
|
|
|
plur.
|
|
|
|
pol.
|
|
|
|
polg.
|
|
|
|
poz.
|
|
|
|
pp.
|
2016-12-21 00:28:20 +03:00
|
|
|
proc.
|
2016-12-08 14:06:36 +03:00
|
|
|
prof.
|
|
|
|
prot.
|
|
|
|
pság.
|
2016-12-21 00:28:20 +03:00
|
|
|
ptk.
|
2016-12-08 14:06:36 +03:00
|
|
|
pu.
|
|
|
|
pü.
|
2016-12-21 00:28:20 +03:00
|
|
|
r.k.
|
2016-12-08 14:06:36 +03:00
|
|
|
rac.
|
|
|
|
rad.
|
|
|
|
red.
|
|
|
|
ref.
|
|
|
|
reg.
|
2016-12-21 00:28:20 +03:00
|
|
|
rer.
|
2016-12-08 14:06:36 +03:00
|
|
|
rev.
|
|
|
|
rf.
|
|
|
|
rkp.
|
|
|
|
rkt.
|
|
|
|
rt.
|
|
|
|
rtg.
|
2016-12-21 00:28:20 +03:00
|
|
|
röv.
|
|
|
|
s.b.
|
|
|
|
s.k.
|
2016-12-08 14:06:36 +03:00
|
|
|
sa.
|
|
|
|
sel.
|
|
|
|
sgt.
|
|
|
|
sm.
|
2017-01-14 17:51:59 +03:00
|
|
|
St.
|
2016-12-08 14:06:36 +03:00
|
|
|
st.
|
|
|
|
stat.
|
2016-12-21 00:28:20 +03:00
|
|
|
stb.
|
2016-12-08 14:06:36 +03:00
|
|
|
strat.
|
|
|
|
sz.
|
|
|
|
szakm.
|
|
|
|
szaksz.
|
|
|
|
szakszerv.
|
|
|
|
szd.
|
|
|
|
szds.
|
|
|
|
szept.
|
|
|
|
szerk.
|
|
|
|
szf.
|
|
|
|
szimf.
|
2016-12-21 00:28:20 +03:00
|
|
|
szjt.
|
2016-12-08 14:06:36 +03:00
|
|
|
szkv.
|
|
|
|
szla.
|
|
|
|
szn.
|
|
|
|
szolg.
|
2016-12-21 00:28:20 +03:00
|
|
|
szt.
|
2016-12-08 14:06:36 +03:00
|
|
|
szubj.
|
2016-12-21 00:28:20 +03:00
|
|
|
szöv.
|
|
|
|
szül.
|
2016-12-08 14:06:36 +03:00
|
|
|
tanm.
|
|
|
|
tb.
|
|
|
|
tbk.
|
|
|
|
tc.
|
|
|
|
techn.
|
|
|
|
tek.
|
2016-12-21 00:28:20 +03:00
|
|
|
tel.
|
2016-12-08 14:06:36 +03:00
|
|
|
tf.
|
|
|
|
tgk.
|
2016-12-21 00:28:20 +03:00
|
|
|
ti.
|
2016-12-08 14:06:36 +03:00
|
|
|
tip.
|
|
|
|
tisztv.
|
|
|
|
titks.
|
|
|
|
tk.
|
|
|
|
tkp.
|
|
|
|
tny.
|
|
|
|
tp.
|
|
|
|
tszf.
|
|
|
|
tszk.
|
|
|
|
tszkv.
|
|
|
|
tv.
|
|
|
|
tvr.
|
2016-12-21 00:28:20 +03:00
|
|
|
ty.
|
|
|
|
törv.
|
|
|
|
tü.
|
2016-12-08 14:06:36 +03:00
|
|
|
ua.
|
|
|
|
ui.
|
|
|
|
unit.
|
|
|
|
uo.
|
|
|
|
uv.
|
|
|
|
vas.
|
|
|
|
vb.
|
|
|
|
vegy.
|
|
|
|
vh.
|
|
|
|
vhol.
|
|
|
|
vill.
|
|
|
|
vizsg.
|
|
|
|
vk.
|
|
|
|
vkf.
|
|
|
|
vkny.
|
|
|
|
vm.
|
|
|
|
vol.
|
|
|
|
vs.
|
|
|
|
vsz.
|
|
|
|
vv.
|
2016-12-21 00:28:20 +03:00
|
|
|
vál.
|
2017-01-14 17:51:59 +03:00
|
|
|
várm.
|
|
|
|
Várm.
|
2016-12-21 00:28:20 +03:00
|
|
|
vízv.
|
|
|
|
vö.
|
2017-01-14 17:51:59 +03:00
|
|
|
Zrt.
|
2016-12-21 00:28:20 +03:00
|
|
|
zrt.
|
|
|
|
zs.
|
|
|
|
Ész.
|
|
|
|
Új-Z.
|
|
|
|
ÚjZ.
|
|
|
|
á.
|
|
|
|
ált.
|
|
|
|
ápr.
|
|
|
|
ásv.
|
|
|
|
é.
|
|
|
|
ék.
|
|
|
|
ény.
|
|
|
|
érk.
|
|
|
|
évf.
|
|
|
|
í.
|
|
|
|
ó.
|
|
|
|
össz.
|
|
|
|
ötk.
|
|
|
|
özv.
|
|
|
|
ú.
|
|
|
|
úm.
|
|
|
|
ún.
|
2017-01-14 17:51:59 +03:00
|
|
|
ú.n.
|
2016-12-21 00:28:20 +03:00
|
|
|
út.
|
|
|
|
üag.
|
|
|
|
üd.
|
|
|
|
üdv.
|
|
|
|
üe.
|
|
|
|
ümk.
|
|
|
|
ütk.
|
|
|
|
üv.
|
|
|
|
ű.
|
|
|
|
őrgy.
|
|
|
|
őrpk.
|
|
|
|
őrv.
|
|
|
|
""".strip().split()
|
|
|
|
|
|
|
|
OTHER_EXC = """
|
|
|
|
-e
|
|
|
|
""".strip().split()
|
2017-01-14 17:51:59 +03:00
|
|
|
|
|
|
|
ORD_NUM_OR_DATE = "([A-Z0-9]+[./-])*(\d+\.?)"
|
|
|
|
_NUM = "[+\-]?\d+([,.]\d+)*"
|
|
|
|
_OPS = "[=<>+\-\*/^()÷%²]"
|
2017-01-14 18:30:11 +03:00
|
|
|
_SUFFIXES = "-[{a}]+".format(a=ALPHA_LOWER)
|
2017-01-14 18:19:15 +03:00
|
|
|
NUMERIC_EXP = "({n})(({o})({n}))*[%]?".format(n=_NUM, o=_OPS)
|
2017-01-14 17:51:59 +03:00
|
|
|
TIME_EXP = "\d+(:\d+)*(\.\d+)?"
|
|
|
|
|
|
|
|
NUMS = "(({ne})|({t})|({on})|({c}))({s})?".format(
|
|
|
|
ne=NUMERIC_EXP, t=TIME_EXP, on=ORD_NUM_OR_DATE,
|
2017-01-14 18:30:11 +03:00
|
|
|
c=CURRENCY, s=_SUFFIXES
|
2017-01-14 17:51:59 +03:00
|
|
|
)
|
|
|
|
|
2017-01-14 17:56:41 +03:00
|
|
|
TOKEN_MATCH = re.compile("^({u})|({n})$".format(u=_URL_PATTERN, n=NUMS)).match
|