Skip to content

Barrier

Bases: BaseModel

A text barrier that consists of one or more tokens.

Parameters:

Name Type Description Default
title str

The title of the barrier.

required
category BarrierCategorization

The category of the barrier; the set of barrier categories is language-specific.

required
description str

A short description of how the barriere impedes text comprehension.

required
suggested_improvement str

How best to resolve the type of the given barrier.

required
affected_tokens list[TokenProtocol] | None

The tokens in a given text that are part of the barrier.

None
Source code in src/limes/models.py
class Barrier(BaseModel):
    """A text barrier that consists of one or more tokens."""

    # Allow arbitrary types for compatibility with TokenProtocol.
    model_config = ConfigDict(arbitrary_types_allowed=True)

    title: str = Field(description="The title of the barrier.")
    category: BarrierCategorization = Field(
        description=(
            "The category of the barrier; the set of barrier categories is "
            "language-specific."
        ),
    )
    description: str = Field(
        description=(
            "A short description of how the barriere impedes text comprehension."
        ),
    )
    suggested_improvement: str = Field(
        description="How best to resolve the type of the given barrier.",
    )
    affected_tokens: list[TokenProtocol] | None = Field(
        default=None,
        description="The tokens in a given text that are part of the barrier.",
    )

    def copy_with(self, affected_tokens: list[TokenProtocol] | None):
        """
        Create a deep copy of the Barrier instance and optionally overwrite
        'affected_tokens'.
        """
        new_barrier = deepcopy(self)
        new_barrier.affected_tokens = affected_tokens
        return new_barrier

copy_with(affected_tokens)

Create a deep copy of the Barrier instance and optionally overwrite 'affected_tokens'.

Source code in src/limes/models.py
def copy_with(self, affected_tokens: list[TokenProtocol] | None):
    """
    Create a deep copy of the Barrier instance and optionally overwrite
    'affected_tokens'.
    """
    new_barrier = deepcopy(self)
    new_barrier.affected_tokens = affected_tokens
    return new_barrier