segram.abc module

segram.abc.labelled(label: str) Callable[source]

Assign label as attribute attr to a function.

class segram.abc.SegramABC[source]

Bases: ABC

Abstract base class for specialized segram classes.

abstract is_comparable_with(other: Any) None[source]

Are self and other comparable.

property hashdata: tuple[Any, ...]

Tuple with hashable objects used for calculating instance hash.

property data: dict[str, Any]

Dictionary mapping names and values for main slots.

get_hashdata() None[source]

Get data used for generating object hash.

classmethod cname(obj: Any | None = None) str[source]

Get class name.

classmethod ppath(obj: Any | None = None) str[source]

Get full python path of the class.

classmethod init_class_attrs(attrs: dict[str, str], **kwds: Any) None[source]

Initialize special class attributes if they are not already defined and set final values.

See init_class_attrs() for details.

copy(**kwds: Any) Self[source]

Copy self and modify attributes with **kwds.

check_comparable(other: Any) None[source]

Raise TypeError if self and other are not comparable.

static are_equal(obj: Any, other: Any, *, strict: bool = True) bool[source]

Are obj and other equal.

Parameters:

strict – Should exact match on class be required. It also means that NLP tokens can be equal only when they live in the same document.

classmethod stringify(obj: Any, **kwds: Any) str[source]

Convert obj to string.

If obj exposes to_str() then it is used with keyword arguments passed in **kwds. Otherwise the plain __repr__() is used.

equal(other: Any, *, strict: bool = True) bool[source]

Are self and other equal.

See iter_diffs() for details.

iter_diffs(other: Any, *, strict: bool = True) Iterable[tuple[str, Any, Any]][source]

Iterate over differences between self and other.

Parameters:

strict – Should exact match on class be required. It also means that NLP tokens can be equal only when they live in the same document.

class segram.abc.SegramWithDocABC[source]

Bases: SegramABC

Abstract base class for segram classes with NLP document objects.

property lang: str

Language code of the document.

get_hashdata() tuple[Any, ...][source]

Get data used for generating object hash.