Skip to content

age

age

Age detection - generally looking for ages of individuals in years or months, so we support 4 digits in a row without any digits before/afterwards and also descriptive words that can describe the age of an individual.

Classes:

Name Description
Age

Determine Age in years or months, or via descriptive terms

Age()

Bases: RegexPredictor

Determine Age in years or months, or via descriptive terms

Source code in src/nemo_safe_synthesizer/pii_replacer/ner/regexes/age.py
def __init__(self):
    entity = Entity.AGE

    age = Pattern(
        pattern=r"(?<!\d)\d{1,4}(?:\.\d*)?(?!\d)",
        header_contexts=HEADERS,
        ignore_raw_score=True,
    )
    desc = Pattern(
        pattern=re.compile(
            r"(?:adult|teen|infant|toddler|child|young|old|elderly|elder)",
            flags=re.IGNORECASE,
        ),
        header_contexts=HEADERS,
        ignore_raw_score=True,
    )

    super().__init__(entity=entity, patterns=[age, desc])