<commit_before>
import datetime
import typing
import warnings
from typing import Dict, List, Optional, Set, Union

import fastobo

from .synonym import SynonymType
from .pv import PropertyValue
from .utils.impl import set
from .utils.meta import roundrepr, typechecked
from .utils.warnings import NotImplementedWarning


@roundrepr
class Subset(object):

    name: str
    description: str

    __slots__ = ("__weakref__", "name", "description")

    @typechecked(property=False)
    def __init__(self, name: str, description: str):
        self.name: str = name
        self.description: str = description

    def __eq__(self, other: object) -> bool:
        if isinstance(other, Subset):
            return (self.name, self.description) == (other.name, other.description)
        return False

    def __lt__(self, other: object) -> bool:
        if not isinstance(other, Subset):
            return typing.cast(bool, NotImplemented)
        return (self.name, self.description) < (other.name, other.description)

    def __hash__(self) -> int:
        return hash((self.name, self.description))


class Metadata(object):
    format_version: str
    data_version: Optional[str]
    ontology: Optional[str]
    date: Optional[datetime.datetime]
    default_namespace: Optional[str]
    namespace_id_rule: Optional[str]
    owl_axioms: List[str]
    saved_by: Optional[str]
    auto_generated_by: Optional[str]
    subsetdefs: Set[Subset]
    imports: Set[str]
    synonymtypedefs: Set[SynonymType]
    idspaces: Dict[str, str]
    remarks: Set[str]
    annotations: Set[PropertyValue]
    unreserved: Dict[str, Set[str]]

    @classmethod
    def _from_ast(cls, header: fastobo.header.HeaderFrame) -> 'Metadata':
        metadata = cls()
<commit_msg>Make `Subset` only compare by name and add total ordering<commit_after>
import datetime
import functools
import typing
import warnings
from typing import Dict, List, Optional, Set, Union

import fastobo

from .synonym import SynonymType
from .pv import PropertyValue
from .utils.impl import set
from .utils.meta import roundrepr, typechecked
from .utils.warnings import NotImplementedWarning


@roundrepr
@functools.total_ordering
class Subset(object):
    """A definition of a subset in an ontology.
    """

    name: str
    description: str

    __slots__ = ("__weakref__", "name", "description")

    @typechecked(property=False)
    def __init__(self, name: str, description: str):
        self.name: str = name
        self.description: str = description

    def __eq__(self, other: object) -> bool:
        if isinstance(other, Subset):
            return self.name == other.name
        return False

    def __lt__(self, other: object) -> bool:
        if not isinstance(other, Subset):
            return typing.cast(bool, NotImplemented)
        return self.name < other.name

    def __hash__(self) -> int:
        return hash((Subset, self.name))


class Metadata(object):
    """A mapping containing metadata about the current ontology.
    """
    format_version: str
    data_version: Optional[str]
    ontology: Optional[str]
    date: Optional[datetime.datetime]
    default_namespace: Optional[str]
    namespace_id_rule: Optional[str]
    owl_axioms: List[str]
    saved_by: Optional[str]
    auto_generated_by: Optional[str]
    subsetdefs: Set[Subset]
    imports: Set[str]
    synonymtypedefs: Set[SynonymType]
    idspaces: Dict[str, str]
    remarks: Set[str]
    annotations: Set[PropertyValue]
    unreserved: Dict[str, Set[str]]

    @classmethod
    def _from_ast(cls, header: fastobo.header.HeaderFrame) -> 'Metadata':
        metadata = cls()

{'fraction_non_alphanumeric': 0.09950385887541345, 'fraction_numerical': 0.0, 'mean_word_length': 3.452760736196319, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '465196', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1075, 'n_words': 312}