spaCy/spacy/lang/id/tokenizer_exceptions.py

51 lines
1.7 KiB
Python
Raw Normal View History

2017-07-23 18:55:05 +03:00
# coding: utf8
from __future__ import unicode_literals
2017-07-26 15:13:47 +03:00
import regex as re
2017-07-24 10:11:51 +03:00
from ._tokenizer_exceptions_list import ID_BASE_EXCEPTIONS
2017-07-26 15:13:47 +03:00
from ..tokenizer_exceptions import URL_PATTERN
2017-07-24 10:12:34 +03:00
from ...symbols import ORTH
2017-07-24 10:11:10 +03:00
2017-07-26 15:13:47 +03:00
2017-07-24 10:11:10 +03:00
_exc = {}
2017-07-26 15:13:47 +03:00
for orth in ID_BASE_EXCEPTIONS:
2017-07-24 10:11:10 +03:00
_exc[orth] = [{ORTH: orth}]
2017-07-26 15:13:47 +03:00
orth_title = orth.title()
_exc[orth_title] = [{ORTH: orth_title}]
orth_caps = orth.upper()
_exc[orth_caps] = [{ORTH: orth_caps}]
orth_lower = orth.lower()
_exc[orth_lower] = [{ORTH: orth_lower}]
if '-' in orth:
orth_title = '-'.join([part.title() for part in orth.split('-')])
_exc[orth_title] = [{ORTH: orth_title}]
orth_caps = '-'.join([part.upper() for part in orth.split('-')])
_exc[orth_caps] = [{ORTH: orth_caps}]
2017-08-20 08:16:50 +03:00
for orth in [
"'d", "a.m.", "Adm.", "Bros.", "co.", "Co.", "Corp.", "D.C.", "Dr.", "e.g.",
"E.g.", "E.G.", "Gen.", "Gov.", "i.e.", "I.e.", "I.E.", "Inc.", "Jr.",
"Ltd.", "Md.", "Messrs.", "Mo.", "Mont.", "Mr.", "Mrs.", "Ms.", "p.m.",
"Ph.D.", "Rep.", "Rev.", "Sen.", "St.", "vs.",
"B.A.", "B.Ch.E.", "B.Sc.", "Dr.", "Dra.", "Drs.", "Hj.", "Ka.", "Kp.",
"M.Ag.", "M.Hum.", "M.Kes,", "M.Kom.", "M.M.", "M.P.", "M.Pd.", "M.Sc.",
"M.Si.", "M.Sn.", "M.T.", "M.Th.", "No.", "Pjs.", "Plt.", "R.A.", "S.Ag.",
"S.E.", "S.H.", "S.Hut.", "S.K.M.", "S.Kedg.", "S.Kedh.", "S.Kom.",
"S.Pd.", "S.Pol.", "S.Psi.", "S.S.", "S.Sos.", "S.T.", "S.Tekp.", "S.Th.",
"a.l.", "a.n.", "a.s.", "b.d.", "d.a.", "d.l.", "d/h", "dkk.", "dll.",
"dr.", "drh.", "ds.", "dsb.", "dst.", "faks.", "fax.", "hlm.", "i/o",
"n.b.", "p.p." "pjs.", "s.d.", "tel.", "u.p.",
]:
_exc[orth] = [{ORTH: orth}]
2017-07-26 15:13:47 +03:00
TOKENIZER_EXCEPTIONS = dict(_exc)
2017-08-20 09:43:21 +03:00