Skip to content

glazing.types

Type definitions and enums used throughout the package.

types

Shared type definitions used across all linguistic resources.

Defines type aliases and literal types used throughout the glazing package for cross-dataset functionality.

Constants

DatasetType : type[Literal] Primary dataset types (FrameNet, PropBank, VerbNet, WordNet). ResourceType : type[Literal] Extended resource types including additional datasets. MappingSource : type[Literal] Mapping source provenance values. LogicType : type[Literal] Logical operators for combining restrictions (or, and). MappingConfidenceScore : type[Annotated[float, Field]] Confidence score for mappings (0.0 to 1.0). VersionString : type[Annotated[str, Field]] Version string following semantic versioning. MappingType : type[Literal] Mapping type classifications. AlignmentType : type[Literal] Alignment types for cross-dataset alignments. ConflictType : type[Literal] Conflict types in mappings. ValidationStatus : type[Literal] Validation status for mappings. OperationType : type[Literal] Common dataset operations. FRAME_ID_PATTERN : str FrameNet frame ID pattern (numeric). VERBNET_CLASS_PATTERN : str VerbNet class ID pattern. VERBNET_KEY_PATTERN : str VerbNet key pattern. LEMMA_PATTERN : str Word lemma pattern. HEX_COLOR_PATTERN : str 6-digit hex color pattern.

Examples:

>>> from glazing.types import DatasetType, MappingSource
>>> dataset: DatasetType = "framenet"
>>> source: MappingSource = "manual"
CLASS DESCRIPTION
DataNotLoadedError

Raised when attempting to access data that hasn't been loaded.

InvalidReferenceError

Raised when a cross-reference cannot be resolved.

MappingConflictError

Raised when conflicting mappings are detected.

ValidationError

Raised when data fails validation against schema.

FUNCTION DESCRIPTION
is_dataset_type

Check if a string is a valid DatasetType.

is_resource_type

Check if a string is a valid ResourceType.

is_valid_confidence

Check if a float is a valid confidence score.

Classes

DataNotLoadedError

Bases: Exception

Raised when attempting to access data that hasn't been loaded.

InvalidReferenceError

Bases: Exception

Raised when a cross-reference cannot be resolved.

MappingConflictError

Bases: Exception

Raised when conflicting mappings are detected.

ValidationError

Bases: Exception

Raised when data fails validation against schema.

Functions

is_dataset_type(value: str) -> bool

Check if a string is a valid DatasetType.

PARAMETER DESCRIPTION
value

The string to check.

TYPE: str

RETURNS DESCRIPTION
bool

True if the value is a valid DatasetType.

Source code in src/glazing/types.py
def is_dataset_type(value: str) -> bool:
    """Check if a string is a valid DatasetType.

    Parameters
    ----------
    value : str
        The string to check.

    Returns
    -------
    bool
        True if the value is a valid DatasetType.
    """
    return value in {"framenet", "propbank", "verbnet", "wordnet"}

is_resource_type(value: str) -> bool

Check if a string is a valid ResourceType.

PARAMETER DESCRIPTION
value

The string to check.

TYPE: str

RETURNS DESCRIPTION
bool

True if the value is a valid ResourceType.

Source code in src/glazing/types.py
def is_resource_type(value: str) -> bool:
    """Check if a string is a valid ResourceType.

    Parameters
    ----------
    value : str
        The string to check.

    Returns
    -------
    bool
        True if the value is a valid ResourceType.
    """
    return value in {
        "verbnet",
        "framenet",
        "wordnet",
        "propbank",
        "VerbNet",
        "FrameNet",
        "WordNet",
        "PropBank",
        "Framenet",
        "AMR",
        "UMR",
        "Flickr",
        "THYME",
        "Spatial",
    }

is_valid_confidence(value: float) -> bool

Check if a float is a valid confidence score.

PARAMETER DESCRIPTION
value

The value to check.

TYPE: float

RETURNS DESCRIPTION
bool

True if the value is between 0.0 and 1.0 inclusive.

Source code in src/glazing/types.py
def is_valid_confidence(value: float) -> bool:
    """Check if a float is a valid confidence score.

    Parameters
    ----------
    value : float
        The value to check.

    Returns
    -------
    bool
        True if the value is between 0.0 and 1.0 inclusive.
    """
    return 0.0 <= value <= 1.0