pcfg-generator
v0.3.0
Published
A module to convert JSON-formated treebank data into a Stochastic Context-Free Grammar
Downloads
9
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