treebank-parser
Version:
A simple parser for treebanks stored in S-Expressions
52 lines (37 loc) • 894 B
Markdown
**Treebank Parser** is a simple parser for treebanks stored in S-Expressions.
To install **treebank-parser** as a module in your project, type the following command.
npm install treebank-parser --save
You can use **treebank-parser** to obtain treebank sentences in a corresponding collection of arrays.
```javascript
var parser = require('treebank-parser');
var treebank = [
'(ROOT'
, ' (S'
, ' (VP (VB Get)'
, ' (NP (NNS coins)))'
, ' (. .)))'
].join('\n');
console.log(JSON.stringify(treebank));
```
This program prints the following output.
```javascript
{
"ROOT_0": {
"S_0": {
"VP_0": {
"VB_0": "Get",
"NP_0": {
"NNS_0": "coins"
}
},
"._0": "."
}
}
}
```
You can run the included unit tests with the following command.
npm test