docria.algorithm

Functions for various processing purposes

Functions

bfs(start, children[, is_result])

Breadth first search

chain(*fns)

Create a new function for a sequence of functions which will be applied in sequence

children_of(layer, *props)

Get children of a given property

dfs(start, children[, is_result])

Depth first search

dfs_leaves(start, children[, is_result])

Depth first search, only returning the leaves i.e. those without children or outgoing links.

dominant_right(segments)

Resolves overlapping segments by using the dominant right rule, i.e. the longest wins and if equal length, the rightmost wins.

dominant_right_span(nodes[, spanfield])

Resolves overlapping spans by using the dominant right rule, i.e. the longest wins and if equal length, the rightmost wins.

get_prop(prop[, default])

First order function which can be used to extract property of nodes

group_by_span(group_nodes, layer_nodes[, ...])

Groups all nodes in layer_nodes into the corresponding bucket_node

is_covered_by(span_a, span_b)

Covered by predicate :type span_a: TextSpan :param span_a: the node that is tested for cover :type span_b: TextSpan :param span_b: the node that might cover span_a :rtype: bool :return: true or false

sequence_to_textspans(token_sequence, text)

Convert a sequence of strings, e.g.

span_translate(doc, mapping_layer, ...)

Translate span ranges from a partial extraction to the original data.