/** Definitions of tree structures. */ import type { Branch, Node, Variable } from './types'; type _Step = [number[], Branch]; export interface TreeOptions { /** Any metadata associated with the tree. */ metadata?: { [key: string]: string; }; } /** * A tree structure. * * A tree is essentially a node that contains other nodes, but this * Tree class is useful to contain any metadata and to provide * tree-based methods. * * `options` consists of the following: * - `metadata`: Any metadata associated with the tree. */ export declare class Tree { node: Node; metadata: { [key: string]: string; }; constructor(node: Node, options?: TreeOptions); /** @ignore */ __eq__(other: any): boolean; /** * Return `true` if this tree is equal to other tree * * Equivalent to `__eq__` in Python */ equals(other: any): boolean; /** @ignore */ __repr__(): string; /** Equivalent to `__repr__` in Python */ pprint(): string; toString(): string; /** * Return the nodes in the tree as a flat list. */ nodes(): Node[]; /** * Iterate over branches in the tree. * * This function yields pairs of (`path`, `branch`) where each * `path` is an array of 0-based indices of branches to get to * `branch`. For example, the path [2, 0] is the concept branch * `('/', 'bark-01')` in the tree for the following PENMAN * string, traversing first to the third (index 2) branch of the * top node, then to the first (index 0) branch of that node: * * ``` * (t / try-01 * :ARG0 (d / dog) * :ARG1 (b / bark-01 * :ARG0 d)) * ``` * * The (`path`, `branch`) pairs are yielded in depth-first order * of the tree traversal. * * @returns An iterator yielding pairs of path and branch in depth-first order. */ walk(): Generator<_Step>; /** * Recreate node variables formatted using `fmt`. * * The `fmt` string can be formatted with the following values: * * - `prefix`: first alphabetic character in the node's concept * - `i`: 0-based index of the current occurrence of the prefix * - `j`: 1-based index starting from the second occurrence */ resetVariables(fmt?: string): void; } /** * Return the variable prefix for `concept`. * * If `concept` is a non-empty string, the prefix is the first * alphabetic character in the string, if there are any, downcased. * Otherwise, the prefix is `'_'`. * * @param concept - The concept to determine the prefix for. * @returns The variable prefix for the given `concept`. * @example * console.log(defaultVariablePrefix('Alphabet')); // Outputs: 'a' * console.log(defaultVariablePrefix('chase-01')); // Outputs: 'c' * console.log(defaultVariablePrefix('"string"')); // Outputs: 's' * console.log(defaultVariablePrefix('_predicate_n_1"')); // Outputs: 'p' * console.log(defaultVariablePrefix(1)); // Outputs: '_' * console.log(defaultVariablePrefix(null)); // Outputs: '_' * console.log(defaultVariablePrefix('')); // Outputs: '_' */ export declare const _defaultVariablePrefix: (concept: any) => Variable; /** * Return `true` if `x` is a valid atomic value. * * @param x - The value to check. * @returns `true` if `x` is a valid atomic value, otherwise `false`. * @example * console.log(isAtomic('a')); // Outputs: true * console.log(isAtomic(null)); // Outputs: true * console.log(isAtomic(3.14)); // Outputs: true * console.log(isAtomic(['a', [['/', 'alpha']]])); // Outputs: false */ export declare const isAtomic: (x: any) => boolean; export {};