-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathpostagger.js
More file actions
38 lines (32 loc) · 921 Bytes
/
postagger.js
File metadata and controls
38 lines (32 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var xmlrpc = require("xmlrpc"),
Trickster = require("./trickster").Trickster;
var trickster = new Trickster();
var Tagger = function(options) {
options = options || {};
var _client = xmlrpc.createClient({
host: options.host || "localhost",
port: options.port || 9000,
path: "/"
});
/**
* Issues an API call to Stanford POS Tagging service to POS tag text.
*
* @param string str
* A blob of text to tag.
*
* @return Array
* The POS tagged text, split into paragraphs.
*/
this.tag = function(str, callback) {
str = trickster.trick(str);
_client.methodCall("tagger.runTagger", [str], function(err, resp) {
if (err) return callback(err);
callback(err, trickster.untrick(resp));
});
};
this.denodeify = function(PromiseLibrary) {
this.tag = PromiseLibrary.denodeify(this.tag);
return this;
};
};
module.exports.Tagger = Tagger;