|
8 | 8 |
|
9 | 9 | EMPTY_REGEX = re.compile('') |
10 | 10 |
|
11 | | -REGEXES = set([ |
12 | | - ("spaces", re.compile(r"\s+")), |
13 | | - ("word", re.compile(r"(\w|\.)+")), |
14 | | - ("mac", re.compile(r'^(ma?c)(\w{2,})', re.I)), |
15 | | - ("initial", re.compile(r'^(\w\.|[A-Z])?$')), |
16 | | - ("quoted_word", re.compile(r'(?<!\w)\'([^\s]*?)\'(?!\w)')), |
17 | | - ("double_quotes", re.compile(r'\"(.*?)\"')), |
18 | | - ("parenthesis", re.compile(r'\((.*?)\)')), |
19 | | - ("roman_numeral", re.compile(r'^(X|IX|IV|V?I{0,3})$', re.I)), |
20 | | - ("no_vowels",re.compile(r'^[^aeyiuo]+$', re.I)), |
21 | | - ("period_not_at_end",re.compile(r'.*\..+$', re.I)), |
22 | | - ("emoji",re_emoji), |
23 | | - ("phd", re.compile(r'\s(ph\.?\s+d\.?)', re.I)), |
24 | | - ("space_before_comma", re.compile(r'\s+,')), |
25 | | - ("east_slavic_patronymic", re.compile( |
| 11 | +REGEXES = { |
| 12 | + "spaces": re.compile(r"\s+"), |
| 13 | + "word": re.compile(r"(\w|\.)+"), |
| 14 | + "mac": re.compile(r'^(ma?c)(\w{2,})', re.I), |
| 15 | + "initial": re.compile(r'^(\w\.|[A-Z])?$'), |
| 16 | + "quoted_word": re.compile(r'(?<!\w)\'([^\s]*?)\'(?!\w)'), |
| 17 | + "double_quotes": re.compile(r'\"(.*?)\"'), |
| 18 | + "parenthesis": re.compile(r'\((.*?)\)'), |
| 19 | + "roman_numeral": re.compile(r'^(X|IX|IV|V?I{0,3})$', re.I), |
| 20 | + "no_vowels": re.compile(r'^[^aeyiuo]+$', re.I), |
| 21 | + "period_not_at_end": re.compile(r'.*\..+$', re.I), |
| 22 | + "emoji": re_emoji, |
| 23 | + "phd": re.compile(r'\s(ph\.?\s+d\.?)', re.I), |
| 24 | + "space_before_comma": re.compile(r'\s+,'), |
| 25 | + "east_slavic_patronymic": re.compile( |
26 | 26 | r'(ovich|ovna|evich|evna|ichna|ilyich|kuzmich|lukich|fomich|fokich)$', |
27 | 27 | re.I, |
28 | | - )), |
29 | | - ("east_slavic_patronymic_cyrillic", re.compile( |
| 28 | + ), |
| 29 | + "east_slavic_patronymic_cyrillic": re.compile( |
30 | 30 | r'(ович|овна|евич|евна|ична|ильич|кузьмич|лукич|фомич|фокич)$', |
31 | 31 | re.I, |
32 | | - )), |
33 | | - ("turkic_patronymic_marker", re.compile( |
| 32 | + ), |
| 33 | + "turkic_patronymic_marker": re.compile( |
34 | 34 | r"^(oglu|oğlu|ogly|ogli|o['’ʻ]g['’ʻ]li" |
35 | 35 | r"|qizi|qızı|kizi|kyzy|gyzy|uly|uulu)$", |
36 | 36 | re.I, |
37 | | - )), |
38 | | - ("turkic_patronymic_marker_cyrillic", re.compile( |
| 37 | + ), |
| 38 | + "turkic_patronymic_marker_cyrillic": re.compile( |
39 | 39 | r'^(оглу|оглы|оғлу|ўғли|угли|кызы|гызы|қызы|қизи|улы|ұлы|уулу)$', |
40 | 40 | re.I, |
41 | | - )), |
42 | | - ("period_abbreviation", re.compile(r'^[^\W\d_]{2,}\.$')), |
43 | | -]) |
| 41 | + ), |
| 42 | + "period_abbreviation": re.compile(r'^[^\W\d_]{2,}\.$'), |
| 43 | +} |
44 | 44 | """ |
45 | 45 | All regular expressions used by the parser are precompiled and stored in the config. |
46 | 46 | """ |
0 commit comments