xissy / node-stanford-simple-nlp

A simple node.js wrapper for stanford-core-nlp.
Other
148 stars 44 forks source link

loadPipeline Initialization #6

Closed latkinso42 closed 10 years ago

latkinso42 commented 10 years ago

I see there has been a recent change in the description of Async vs Sync. This is a great step foreword.

However, for me, The code example for the Async mode still reports 'Load a pipeline first'. Also the Warning has an effective double negative "didn't" and "without" which is a bit confusing with respect to both examples..

Respectfully...

xissy commented 10 years ago

Sorry to hear, @latkinso42. Could you write your code here? Let me inspect the problem please.

latkinso42 commented 10 years ago

So it seems this was a java CLASSPATH issue. There was a difference in the errors from the Async technique and the Sync technique, but this is most likely due to the loadPipeline requirement. Both are working now, for me.

My node app.js employs a typical routes.js for get and post. The callback for the post calls a handler which uses either the async or sync method as below. The post callback generally renders the output from the results of the parser and the params contain the text query:

var StanfordSimpleNLP = require('../../lib/StanfordSimpleNLP');

// ASYNC exports.parsePhrase = function(params, callback) { var ssnlp=new StanfordSimpleNLP( function(err) { ssnlp.process(params.tquery, callback); }); }

// SYNC exports.parsePhrase = function(params, callback) { var stanfordSimpleNLP = new StanfordSimpleNLP(null, callback); stanfordSimpleNLP.loadPipelineSync(); stanfordSimpleNLP.process(params.tquery, function(err, result) { callback(err, result);}); }

Every thing works either way! Thanks!

xissy commented 10 years ago

Good job! I know that the setting java & node-java is not easy in some environments.

hypersundays commented 10 years ago

I'm having a problem using the node wrapper.

When I use this: var stanfordSimpleNLP = new StanfordSimpleNLP.StanfordSimpleNLP(function(err, callback) { stanfordSimpleNLP.process('This is so good.', function(err, result) { console.log(err, result); if (err){ return err; } console.log(result); });

I get the 'load a pipeline first' error.

When I use this:

var stanfordSimpleNLP = new StanfordSimpleNLP(function(err){ // same code as above

I get the object is not a function TypeError.

I'm trying to find a way to make this work but I can't quite understand where to go from here.

Izhaki commented 8 years ago

Same issue as @hypersundays. Extracting the slp zip into the jar folder solved it.

See https://github.com/xissy/node-stanford-simple-nlp/tree/master/jar