pyeeg.features.SyntacticFeatureExtractor.depth_single_tree
- SyntacticFeatureExtractor.depth_single_tree(tree: None, remove_S: bool = True, remove_unibranch_offset: bool = True) List[int]
Get depth of each leaf in the parse tree.
Computes the depth of every leaf (word) as the length of its tree position after collapsing unary productions. An offset can be subtracted to account for the root-level sentence node (
S) and unary-branching nodes.Based on parseMetrics.py.
- Parameters:
tree (nltk.tree.Tree) – Constituency parse tree.
remove_S (bool) – Whether to subtract 1 from each depth to discount the root
Snode. Default:True.remove_unibranch_offset (bool) – Whether to subtract an additional 1 from each depth to discount unary-branching nodes collapsed by
collapse_unary. Default:True.
- Returns:
depths – Depth of each leaf, in leaf (word) order. Length equals the number of leaves in
tree.- Return type: