Skip to content

error_types

Error type symbols and their corresponding error categories.

These symbols are used in the markup syntax to indicate different types of errors: - Basic syntax: {error}${correction} - Nested syntax: {{error1}${correction_of_error1}}£{correction_of_correction1}

ErrorMarkupError

Bases: Exception

This is raised for errors in this module.

Source code in corpustools/error_types.py
111
112
113
114
class ErrorMarkupError(Exception):
    """This is raised for errors in this module."""

    pass

ErrorType

Bases: Enum

Error type enumeration with associated symbols.

Each error type has: - An enum name (built-in .name attribute) - A symbol character used in markup - A string representation for serialization

Source code in corpustools/error_types.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class ErrorType(Enum):
    """Error type enumeration with associated symbols.

    Each error type has:
    - An enum name (built-in .name attribute)
    - A symbol character used in markup
    - A string representation for serialization
    """

    # Orthographic error (spelling)
    ERRORORT = ("errorort", "$")

    # Real orthographic error
    ERRORORTREAL = ("errorortreal", "¢")

    # Lexical error
    ERRORLEX = ("errorlex", "€")

    # Morphosyntactic error
    ERRORMORPHSYN = ("errormorphsyn", "£")

    # Syntactic error
    ERRORSYN = ("errorsyn", "¥")

    # Generic error
    ERROR = ("error", "§")

    # Language error
    ERRORLANG = ("errorlang", "∞")

    # Format error
    ERRORFORMAT = ("errorformat", "‰")

    @property
    def symbol(self) -> str:
        """Get the symbol character for this error type."""
        return self.value[1]

    @property
    def error_name(self) -> str:
        """Get the error type name as a string (e.g., 'errorort')."""
        return self.value[0]

    def __str__(self) -> str:
        """String representation returns the error name (e.g., 'errorort')."""
        return self.error_name

error_name property

Get the error type name as a string (e.g., 'errorort').

symbol property

Get the symbol character for this error type.

__str__()

String representation returns the error name (e.g., 'errorort').

Source code in corpustools/error_types.py
71
72
73
def __str__(self) -> str:
    """String representation returns the error name (e.g., 'errorort')."""
    return self.error_name

all_error_symbols()

Get all valid error type symbols.

Returns:

Type Description
list[str]

List of all symbol characters

Example

all_error_symbols() ['$', '¢', '€', '£', '¥', '§', '∞', '‰']

Source code in corpustools/error_types.py
 98
 99
100
101
102
103
104
105
106
107
108
def all_error_symbols() -> list[str]:
    """Get all valid error type symbols.

    Returns:
        List of all symbol characters

    Example:
        >>> all_error_symbols()
        ['$', '¢', '€', '£', '¥', '§', '∞', '‰']
    """
    return [error_type.symbol for error_type in ErrorType]

error_type_from_symbol(symbol)

Parse an error type from a symbol character.

Parameters:

Name Type Description Default
symbol str

The symbol character to look up

required

Returns:

Type Description
ErrorType | None

The corresponding ErrorType, or None if symbol is invalid

Example

error_type_from_symbol("$")

Source code in corpustools/error_types.py
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
def error_type_from_symbol(symbol: str) -> ErrorType | None:
    """Parse an error type from a symbol character.

    Args:
        symbol: The symbol character to look up

    Returns:
        The corresponding ErrorType, or None if symbol is invalid

    Example:
        >>> error_type_from_symbol("$")
        <ErrorType.ERRORORT: ('errorort', '$')>
    """
    for error_type in ErrorType:
        if error_type.symbol == symbol:
            return error_type
    return None