def get_span_literal(span):
    """Get the literal value from an entity's TargetRule, which is set when an entity is extracted by TargetMatcher.
    If the span does not have a TargetRule, it returns the lower-cased text.
    """
    target_rule = span._.target_rule
    if target_rule is None:
        return span.text.lower()
    return target_rule.literal