-
Notifications
You must be signed in to change notification settings - Fork 0
/
en.py
36 lines (26 loc) · 1.45 KB
/
en.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Importing this module adds English transducers to the master transducer `transducer.master`.
"""
import gettext
import config
from transducer import master, WordsNbspSubstituter
_ = gettext.translation(config.domain, localedir=config.localedir, fallback=True).gettext
# Groups:
lang_en = master.add_group('en', _('English language'))
punctuation = master.add_group('punctuation')
ellipsis = master.add_group('ellipsis')
# http://www.chicagomanualofstyle.org/qanda/data/faq/topics/SpecialCharacters/faq0003.html
# http://practicaltypography.com/ellipses.html
# Transducers:
ellipsis_periods_after_period = WordsNbspSubstituter([r'\. \.'] + [r'\.'] * 2, 'ellipsis_periods_after_period')
ellipsis_periods_after_period.examples = ['I am fine. . . . And you?']
master.add(ellipsis_periods_after_period, [lang_en, punctuation, ellipsis])
ellipsis_periods_after_word = WordsNbspSubstituter([r'\w'] + [r'\.'] * 3, 'ellipsis_periods_after_word')
ellipsis_periods_after_word.examples = ['And so on . . .']
master.add(ellipsis_periods_after_word, [lang_en, punctuation, ellipsis])
ellipsis_periods = WordsNbspSubstituter([r'\.'] * 3, 'ellipsis_periods')
ellipsis_periods.examples = ['1, 2, 3, . . .']
master.add(ellipsis_periods, [lang_en, punctuation, ellipsis])
ellipsis_special = WordsNbspSubstituter([r'\w', r'(?:…|…)'], 'ellipsis_special')
ellipsis_special.examples = ['And so on …', 'And so on …']
master.add(ellipsis_special, [lang_en, punctuation, ellipsis])