def parse_year(s): years = filter(lambda t: len(t) == 4 and t.startswith("19") or t.startswith("200"), text.uniques(s)) if len(years) > 0: return text.norm(years[0])
def parse_month(s): months = filter(lambda m: m is not None, map(month_lookup, text.uniques(s))) if len(months) > 0: return text.norm(months[0])