Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

pcfg-generator

filch25AGPL-3.00.3.0

A module to convert JSON-formated treebank data into a Stochastic Context-Free Grammar

treebank, pcfg, nlp

readme

pcfg-generator

pcfg-generator is a Node.js module to convert the output from treebank-parser into a Stochastic Context Free Grammar.

Install

To install pcfg-generator into your project, enter the following command in your project's root directory.

npm install pcfg-generator --save

NOTE: You might also want to consider installing treebank-parser as well.

Use

The following example shows how you can use pcfg-generator in your project.

var fs              = require('fs')
  , treebank_parser = require('treebank-parser')
  , pcfg_generator  = require('pcfg-generator')
  ;

var treebank_json = treebank_parser.parse(s_expression);
var pcfg = pcfg_generator.generate(treebank_json);

console.log(JSON.stringify(pcfg, null, 2));

Test

To run the included unit tests, enter the following command.

npm test