2015-04-07 01:45:18 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
_mw_prepositions = [
|
|
|
|
'close to',
|
|
|
|
'down by',
|
|
|
|
'on the way to',
|
2015-04-15 23:35:46 +00:00
|
|
|
'on my way to',
|
2015-04-07 01:45:18 +00:00
|
|
|
'on my way',
|
2015-04-15 23:35:46 +00:00
|
|
|
'on his way to',
|
2015-04-07 01:45:18 +00:00
|
|
|
'on his way',
|
2015-04-15 23:35:46 +00:00
|
|
|
'on her way to',
|
2015-04-07 01:45:18 +00:00
|
|
|
'on her way',
|
2015-04-15 23:35:46 +00:00
|
|
|
'on your way to',
|
2015-04-07 01:45:18 +00:00
|
|
|
'on your way',
|
2015-04-15 23:35:46 +00:00
|
|
|
'on our way to',
|
2015-04-07 01:45:18 +00:00
|
|
|
'on our way',
|
2015-04-15 23:35:46 +00:00
|
|
|
'on their way to',
|
2015-04-07 01:45:18 +00:00
|
|
|
'on their way',
|
2015-04-17 02:44:24 +00:00
|
|
|
'along the route from'
|
2015-04-07 01:45:18 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
MW_PREPOSITIONS_RE = re.compile('|'.join(_mw_prepositions), flags=re.IGNORECASE)
|
|
|
|
|
|
|
|
|
|
|
|
TIME_RE = re.compile(
|
|
|
|
'{colon_digits}|{colon_digits} ?{am_pm}?|{one_two_digits} ?({am_pm})'.format(
|
|
|
|
colon_digits=r'[0-2]?[0-9]:[0-5][0-9](?::[0-5][0-9])?',
|
|
|
|
one_two_digits=r'[0-2]?[0-9]',
|
|
|
|
am_pm=r'[ap]\.?m\.?'))
|
|
|
|
|
2015-04-17 02:44:24 +00:00
|
|
|
DATE_RE = re.compile(
|
|
|
|
'(?:this|last|next|the) (?:week|weekend|{days})'.format(
|
|
|
|
days='Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday'
|
|
|
|
))
|
|
|
|
|
2015-04-07 01:45:18 +00:00
|
|
|
|
|
|
|
MONEY_RE = re.compile('\$\d+(?:\.\d+)?|\d+ dollars(?: \d+ cents)?')
|
|
|
|
|
|
|
|
|
|
|
|
DAYS_RE = re.compile('Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday')
|
|
|
|
|
|
|
|
|
|
|
|
REGEXES = [('IN', 'O', MW_PREPOSITIONS_RE), ('CD', 'TIME', TIME_RE),
|
2015-04-17 02:44:24 +00:00
|
|
|
('NNP', 'DATE', DATE_RE),
|
2015-04-07 01:45:18 +00:00
|
|
|
('NNP', 'DATE', DAYS_RE), ('CD', 'MONEY', MONEY_RE)]
|