node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

node-stanford-postagger

Node Stanford POS-tagger

A node.js client to interact with Stanford's POS-tagger.

Usage

node-stanford-postagger has one usage, to interact with Stanford's POS-tagger.

Dependencies

Installation

git clone https://github.com/cuzzo/node-stanford-postagger
cd node-stanford-postagger
npm install

How to POS-tag

util/run-server.sh is a script that runs Turian's XMLRPC service for Stanford's POS-tagger in a user-friendly way.

run-server.sh models/left3words-wsj-0-18.tagger 9000

The above runs the service using the built-in left3words-wsj-0-18 training model on port 9000. To run this script, it's required to live in the root directory of the stanford-postagger code--in the same directory as Turian's tagger-server.jar is required to be moved.

Once the server is running, you can run:

bin/tag "Hello, world!"

You'll get back:

[ 'Hello_UH ,_, world_NN !_.\n' ]

Interacting with Stanford's POS-tagger in Your node.js Project

var Tagger = require("node-stanfrod-postagger/postagger").Tagger;
var tagger = new Tagger({
  port: "9000",
  host: "localhost"
});
 
tagger.tag("Hello, world!", function(err, resp) {
  console.log(err, resp);
});

If you don't like callbacks and prefer promises, node-stanford-postagger supports denodeify.

var Q = require("q");
var Tagger = require("node-stanfrod-postagger/postagger").Tagger;
var tagger = new Tagger({
  port: "9000",
  host: "localhost"
});
tagger.denodify(Q);
 
tagger.tag("Hello, world!")
  .then(function(resp) {
      console.log(resp);
    },
    function(err) {
      console.log(err);
    }
  );

Acknowledgements

License

node-stanford-postagger is free--as in BSD. Hack your heart out, hackers.