Download this file

17 lines (11 with data), 406 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
import re
from .base import ExactMatchGenerator
AGE_REGEX = re.compile(r'\d+')
class AgeSurrogates(ExactMatchGenerator):
def replace_one(self, annotation):
for match in AGE_REGEX.finditer(annotation):
age = int(match.group(0))
if age > 89:
age = 89
annotation = re.sub(match.group(0), str(age), annotation)
return annotation