Skip to main content

parse

Function: parse

parse(s): Tree

Parse a PENMAN-notation string s into its tree structure.

Example

import { parse } from 'penman-js';

const tree = parse('(b / bark-01 :ARG0 (d / dog))');
console.log(tree);

// Tree(['b', [['/', 'bark-01'], [':ARG0', ['d', [['/', 'dog']]]]])

Function: iterparse

iterparse(lines): IterableIterator<Tree>

Yield trees parsed from lines.

Example

import { iterparse } from 'penman-js';

for (const t of iterparse('(a / alpha) (b / beta)')) {
console.log(t);
}

// Tree(['a', [['/', 'alpha']]])
// Tree(['b', [['/', 'beta']]])

Function: parseTriples

parseTriples(s): Triple[]

Parse a triple conjunction from s.

Example

import { parseTriples } from 'penman-js';

for (const triple of parseTriples(`
instance(b, bark) ^
ARG0(b, d) ^
instance(d, dog)`)) {
console.log(triple);
// ['b', ':instance', 'bark']
// ['b', ':ARG0', 'd']
// ['d', ':instance', 'dog']
}