text_lint.results.tree.ResultTree

class text_lint.results.tree.ResultTree(value: str | List[str])[source]

Bases: object

Nested parsing results represented as tree.

__eq__(other: object) bool[source]

Implement the equality operator for ResultTree instances.

Parameters:

other (object) – The other object to compare to this ResultTree instance.

Returns:

A boolean for whether this tree is equal to the specified tree.

Raises:

NotImplemented

Return type:

bool

__hash__() int[source]

Implement hashing for ResultTree instances.

Returns:

The hashed value of this tree.

Return type:

int

__init__(value: str | List[str]) None[source]

Initialize ResultTree instances.

Parameters:

value (str | List[str]) – The root value of the new ResultTree.

add_matches(capture_groups: Tuple[str | List[str], ...], splits: Dict[int, str | None], index: int = 0) None[source]

Add a set of capture groups to the tree.

Parameters:
  • capture_groups (Tuple[str | List[str], ...]) – A tuple of values captured from assertion regexes.

  • splits (Dict[int, str | None]) – A dictionary of splits to perform on the captured values.

  • index (int) – The index of the current captured value being processed.

clone() ResultTree[source]

Generate a separate copy of this tree.

Returns:

The cloned tree instance.

Return type:

ResultTree

classmethod create(value: str | List[str]) ResultTree[source]

Create a new ResultTree instance.

Parameters:

value (str | List[str]) – The root value of the new ResultTree.

Returns:

The created tree.

Return type:

ResultTree

representation() Dict[str | List[str], str | List[str] | List[AliasRecursiveTreeResult]][source]

Return a dictionary representation of the nested tree structure.

Returns:

A dictionary representation of this tree.

Return type:

Dict[str | List[str], str | List[str] | List[AliasRecursiveTreeResult]]