phrase-tree

1.0.0 • Public • Published

Phrase Tree

Converts the penn tagged phrase structure tree from the Stanford parser to a regular Javascript object tree.

Install

npm install phrase-tree

Usage

// inputFromParser =
//  (S
//    (NP (DT The) (NN boy))
//    (VP (VBD saw)
//      (NP (DT a) (NN dog)))))
 
var convert = require('phrase-tree')
var tree = convert(inputFromParser)
 
console.log(JSON.stringify(tree, null, 2))
//{
//  "tag": "S",
//  "tex": "",
//  "children": [
//    {
//      "tag": "NP",
//      "tex": "",
//      "children": [
//        {
//          "tag": "DT",
//          "tex": "The",
//          "children": []
//        },
//        {
//          "tag": "NN",
//          "tex": "boy",
//          "children": []
//        }
//      ]
//    },
//    {
//      "tag": "VP",
//      "tex": "",
//      "children": [
//        {
//          "tag": "VBD",
//          "tex": "saw",
//          "children": []
//        },
//        {
//          "tag": "NP",
//          "tex": "",
//          "children": [
//            {
//              "tag": "DT",
//              "tex": "a",
//              "children": []
//            },
//            {
//              "tag": "NN",
//              "tex": "dog",
//              "children": []
//            }
//          ]
//        }
//      ]
//    }
//  ]
//}

License

MIT © Harris Jose

js-standard-style

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.01latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.01

Package Sidebar

Install

npm i phrase-tree

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • harrisjose