将Apache Open NLP与node.js结合使用的最佳方法是什么?
具体来说,我想使用名称实体提取API。这是关于它的内容-文档太糟糕了(我认为是新项目):
http://opennlp.apache.org/documentation/manual/opennlp.html#tools.namefind
从文档中:
InputStream modelIn = new FileInputStream("en-ner-person.bin");
try {
TokenNameFinderModel model = new TokenNameFinderModel(modelIn);
}
catch (IOException e) {
e.printStackTrace();
}
finally {
if (modelIn != null) {
try {
modelIn.close();
}
catch (IOException e) {
}
}
}
NameFinderME nameFinder = new NameFinderME(model);
for (String document[][] : documents) {
for (String[] sentence : document) {
Span nameSpans[] = find(sentence);
// do something with the names
}
nameFinder.clearAdaptiveData()
}
the following snippet shows a call to find
String sentence = new String[]{
"Pierre",
"Vinken",
"is",
"61",
"years"
"old",
"."
};
Span nameSpans[] = nameFinder.find(sentence);
最佳答案
checkout 此NodeJS库。
https://github.com/mbejda/Node-OpenNLP
https://www.npmjs.com/package/opennlp
只做 NPM安装opennlp
并查看Github上的示例。
var nameFinder = new openNLP().nameFinder;
nameFinder.find(sentence, function(err, results) {
console.log(results)
});
关于multithreading - 如何在node.js应用程序中使用Apache OpenNLP,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24353186/