segram.utils.diff module
- segram.utils.diff.equal(obj, other, *, strict: bool = True) bool[source]
- segram.utils.diff.equal(obj: Token, other: Token, *, strict: bool = True) bool
- segram.utils.diff.equal(obj: Span, other: Span, *, strict: bool = True) bool
- segram.utils.diff.equal(obj: Doc, other: Doc, *, strict: bool = True) bool
Compare two arbitrary objects.
Objects are compared using standard equality operator, unless they are
SegramABCinstance, in which case theequal()method is used.- Parameters:
obj – Arbitrary objects.
other – Arbitrary objects.
strict – Passed to
.equal()method.
- segram.utils.diff.iter_diffs(obj, other, *, strict: bool = True) Iterable[tuple[str, Any, Any]][source]
- segram.utils.diff.iter_diffs(obj: tuple, other: tuple, *, strict: bool = True) Iterable[tuple[str, Any, Any]]
- segram.utils.diff.iter_diffs(obj: list, other: list, *, strict: bool = True) Iterable[tuple[str, Any, Any]]
- segram.utils.diff.iter_diffs(obj: Mapping, other: Mapping, *, strict: bool = True) Iterable[tuple[str, Any, Any]]
- segram.utils.diff.iter_diffs(obj: Token, other: Token, *, strict: bool = True) Iterable[tuple[str, Any, Any]]
- segram.utils.diff.iter_diffs(obj: Span, other: Span, *, strict: bool = True) Iterable[tuple[str, Any, Any]]
- segram.utils.diff.iter_diffs(obj: Doc, other: Doc, *, strict: bool = True) Iterable[tuple[str, Any, Any]]
- segram.utils.diff.iter_diffs(obj: SegramABC, other: Any, *, strict: bool = True) Iterable[tuple[str, Any, Any]]
Single dispatch generic function for iterating over differences between two objects.
- Parameters:
obj – Two arbitrary objects. The method dispatch is done on
objtype.other – Two arbitrary objects. The method dispatch is done on
objtype.strict – Used for comparing NLP token objects and grammar/semantic objects. When
strict=Trueonly exact matches on classes are accepted. This means, for instance, that only tokens from the same document can be equal, regardless of any text and index equivalences between two tokens and documents.
- Yields:
qname – Qualified name of
objor its type.name – Name of the attribute/property that differs between
objandother.v1, v2 – Values that differ.