# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .grammar_category import GrammarCategory


class GrammarChange(UniversalBaseModel):
    original: str = pydantic.Field()
    """
    The original text
    """

    modified: str = pydantic.Field()
    """
    The modified text
    """

    change_start_char_idx: typing.Optional[int] = pydantic.Field(default=None)
    """
    The start index of the change (calculated from context)
    """

    change_type: typing.Optional[typing.Literal["grammar"]] = None
    context_before: typing.Optional[str] = pydantic.Field(default=None)
    """
    Text that appears before the original text
    """

    context_after: typing.Optional[str] = pydantic.Field(default=None)
    """
    Text that appears after the original text
    """

    category: GrammarCategory

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
