我试图通过引用https://www.npmjs.org/package/treetagger来运行treetagger,但我收到了以下错误。
TypeError: Object function TreeTagger(options) {
events.EventEmitter.call(this);
this.options = options || {};
this.encoding = this.options.encoding || 'latin-1';
this.language = this.options.language || 'english';
this.paths = ['.', '/usr/bin', '/usr/local/bin', '/opt/local/bin',
'/Applications/bin', '~/bin', '~/Applications/bin'];
this.envVars = ["TREETAGGER", "TREETAGGER_HOME"];
// Validate the given encoding and language selected
if (!this.encoding in languages) {
throw new Error("Unsupported encoding detected " + this.encoding);
}
if (languages[this.encoding].indexOf(this.language) < 0) {
throw new Error("Unsupported language detected " + this.language + " for encoding " + this.encoding);
}
// Set the appropriate bin path
if (this.encoding == "latin-1") {
this.binPath = 'tree-tagger-' + this.language;
}
else {
this.binPath = 'tree-tagger-' + this.language + '-' + this.encoding;
}
this.binPath = findPath(this.binPath, this.paths, this.envVars);
} has no method 'tag'
答案 0 :(得分:0)
事实上,自述文件中存在一个问题,应该是:
var TreeTagger = require('treetagger');
var tagger = new TreeTagger();
tagger.tag("This is a test!", function (err, results) {
console.log(results);
});
我向图书馆作者发送了pull-request来解决此问题。