# pcfg-generator

**pcfg-generator** is a [Node.js](http://nodejs.org/) module to convert the output from [treebank-parser](https://gitorious.org/filch/treebank-parser/) into a [Stochastic Context Free Grammar](https://en.wikipedia.org/w/index.php?title=Stochastic_context-free_grammar&oldid=624573923).

## 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](https://gitorious.org/filch/treebank-parser/) as well.

## Use

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

```javascript
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
