Class Node<T>Abstract

This is an implementation class, used as a super data class of Token and TectoToken. We use the word node to refer to both tokens and tecto-tokens. In general, we assume that any tree can be non-projective (i.e. generated by context-sensitive grammar), even though the linear order of tecto-tokens has no meaning.

All nodes in the tree have to be of the same type: either all Tokens or all TectoTokens.

Type Parameters

Hierarchy (View Summary)

Implements

Constructors

Properties

children: T[] = []

Nodes that depend on this node, ordered by word-order; empty for leafs or if no tree-structure is in the analysis.

id: string

ID of this node used to refer to it from other objects.

idx: number

Zero-based index of this node reflecting its word-order position within the sentence.

parent: null | T = null

Node that this node depends on. Null for the root or if no tree-structure is in the analysis.

sentence: Sentence

Sentence this node belongs to. Can be null only during construction.

Methods

  • All nodes dominated by this node.

    Parameters

    • reflexive: boolean = true

      Whether this node itself is included.

    • ordered: boolean = true

      Whether the result should be ordered by word order.

    Returns T[]

  • Depth of this node in the dependency tree.

    Returns number

    The distance, i.e. number of dependency edges, from the root of the sentence.

  • In-order iterator over the subtree of this node, optionally skipping some subtrees.

    Parameters

    • includeFilteredRoot: boolean = true

      If true, the nodes on which [skipPredicate] returns true are included in the result.

    • skipPredicate: (n: T) => boolean

      When this predicate is true on any node, the node's subtree is not traversed (skipping only their subtrees).

    Returns Iterable<T>

  • Pre-order iterator over the subtree of this node, optionally skipping some subtrees.

    Parameters

    • includeFilteredRoot: boolean = true

      If true, the nodes on which [skipPredicate] returns true are included in the result (skipping only their subtrees).

    • skipPredicate: (n: T) => boolean

      When this predicate is true on any node, the node's subtree is not traversed.

    Returns Iterable<T>

  • In-order iterator over the subtree of this node.

    Returns Iterable<T>

  • Checks if the phrase dominated by this node is continuous.

    Returns boolean

  • Check whether this node is a leaf (i.e has no dependents).

    Returns boolean

  • Check whether this node is the root of the sentence.

    Returns boolean

  • Pre-order iterator over the subtree of this node.

    Returns Iterable<T>

  • Indented string representation of the subtree of this node.

    Parameters

    • printToken: (token: T) => string

      A function printing individual nodes.

    • indentStr: string = " "

      A string used to indent each level from the previous one.

    • depth: number = 0

      Indentation level to start with.

    Returns string

  • Simple indented representation of this tree using toSimpleString to convert individual nodes.

    Returns string

  • Non-recursive string representation of this node.

    Returns string

  • Simple representation of this tree using toSimpleString to convert individual nodes.

    Returns string

  • Parenthesised representation of the subtree of this node.

    Parameters

    • printToken: (token: T) => string

      Function printing individual nodes.

    Returns string

    A string representation of the tree rooted in this node.