gram_ops


gram.js API

Globals / gram-ops

Package: gram-ops

(ast)-[ops]->(features)

Utility operations for extracting path features from gram AST.

How to gram-ops

Install:

npm install @gram-data/gram-ops

Build a path

Use gram-builder to create a path.

import { node, edge } from '@gram-data/gram-builder';

const left = node('a');
const right = node('b');
const path = edge([left, right], 'right');

Extract features from the path

Extract a node list:

import { nodes } from '@gram-data/gram-ops';

const ns:GramPath[] = nodes(path); 

Extract an edge list:

import { nodes } from '@gram-data/gram-ops';

const es:GramPath[] = edges(path); 

Next Steps

Index

Functions

Functions

count

Constcount(p: GramPath): number

Defined in packages/gram-ops/src/index.ts:11

Parameters:

Name Type
p GramPath

Returns: number


edges

Constedges(p: GramPath): GramEdge[]

Defined in packages/gram-ops/src/index.ts:70

Parameters:

Name Type
p GramPath

Returns: GramEdge[]


Consthead(p: GramPath): GramNode

Defined in packages/gram-ops/src/index.ts:18

Parameters:

Name Type
p GramPath

Returns: GramNode


identity

Constidentity(p: GramPath): undefined | string

Defined in packages/gram-ops/src/index.ts:35

Parameters:

Name Type
p GramPath

Returns: undefined | string


merge

Constmerge(_: GramPath, next: GramPath): GramPath

Defined in packages/gram-ops/src/index.ts:30

Parameters:

Name Type
_ GramPath
next GramPath

Returns: GramPath


nodes

Constnodes(p: GramPath | GramPath[] | GramSeq): GramNode[]

Defined in packages/gram-ops/src/index.ts:44

Node set projected from within a path.

Parameters:

Name Type Description
p GramPath | GramPath[] | GramSeq paths from which to project nodes

Returns: GramNode[]


tail

Consttail(p: GramPath): GramNode

Defined in packages/gram-ops/src/index.ts:24

Parameters:

Name Type
p GramPath

Returns: GramNode