Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Question about usage #29

Open
Open
Labels
@owendall

Description

Hi,

So glad to see a node interface to CoreNLP.

As I am new to working with this API, I am wondering the best practices with starting from a document and working through sentences.

Suggestions for enhancing the following code and links to any examples would be much appreciated!

// 2017年11月25日 learning corenlp v1.1.8
// The coreNLP server is a Docker image mapped to port 9000
require("babel-polyfill");
// Need this polyfill even if you are not using async/await.
// I received this error in both node.js 7.8.0 and node.js 8.5.0:
//------ /Users/owendall/Desktop/github-applications/ai/core-nlp-test/node_modules/corenlp/dist/pipeline.js:139
//----- var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(annotable) {
//----- ReferenceError: regeneratorRuntime is not defined
const corenlp = require("corenlp");
const coreNLP = corenlp.default; // convenient when not using `import`
const connector = new corenlp.ConnectorServer({
 dsn: 'http://localhost:9000',
});
// initialize the pipeline and document to annotate
const props = new corenlp.Properties({
 annotators: 'ssplit,tokenize,pos,ner,parse'
});
const pipeline = new corenlp.Pipeline(props, 'English', connector);
console.log("Pipeline Details: ",JSON.stringify(pipeline, null,2));// Let's look at the internals
const doc = new coreNLP.simple.Document(
 'I live on the river, close to the river bank. I had an old boat on the river. I used the boat on the river every day.'
);
console.log(JSON.stringify(doc,null,2));
pipeline.annotate(doc)
 .then(function(doc) {
 var sentenceArray = doc.sentences();
 console.log("Found "+ sentenceArray.length + " sentences"); 
 console.log("sentenceArray: ",JSON.stringify(sentenceArray,null,2));
 sentenceArray.map(function(sentence){
 console.log("Sentence: ", sentence)
 });
 })
 .catch(function(err) {
 console.log('err', err);
 });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /