node-stanford-postagger
v0.0.1
Published
Asynchronous POS-tagging with Stanford's POS-tagger!
Downloads
39
Maintainers
Readme
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
- Ali Afshar's XMLRPC service for Stanford's POS-tagger - This node.js client wouldn't exist without it.
- The geniuses at Stanford - These guys were and are truly pioneering. This software gets the part of speech right 90% of the time, even when the word is unknown!
License
node-stanford-postagger is free--as in BSD. Hack your heart out, hackers.