Spaces:
Configuration error
Configuration error
File size: 1,112 Bytes
4a14841 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | """Markers for Data Card fields that have no value."""
from typing import Any
# The sources were read, but none of them states this value.
NOT_REPORTED = "not_reported"
# The field does not apply to this model, e.g. tokenization for an image model.
NOT_APPLICABLE = "not_applicable"
# No value was extracted: the source or the LLM call failed, or the field was
# never filled.
NOT_RETRIEVED = "not_retrieved"
MISSING_MARKERS = (NOT_REPORTED, NOT_APPLICABLE, NOT_RETRIEVED)
# Older Data Cards use "N/A" and similar strings for every missing value.
LEGACY_MISSING = {"", "n/a", "na", "none", "null", "unknown", "not available"}
MISSING_VALUES = LEGACY_MISSING | set(MISSING_MARKERS)
def is_missing(value: Any) -> bool:
"""True for None, empty containers, legacy empty strings, and the markers."""
if value is None:
return True
if isinstance(value, (list, dict)):
return not value
return isinstance(value, str) and value.strip().lower() in MISSING_VALUES
def is_legacy_missing(value: Any) -> bool:
return isinstance(value, str) and value.strip().lower() in LEGACY_MISSING
|