Giter Club home page Giter Club logo

node-corenlp's Introduction

CoreNLP for NodeJS

This library helps making NodeJS/Web applications using the state-of-the-art technology for Natural Language Processing: Stanford CoreNLP. It is compatible with the latest release of CoreNLP 3.9.0.

Build Status Try corenlp on RunKit

NPM package

This project is under active development, please stay tuned for updates. More documentation and examples are comming.

Example

Assuming that StanfordCoreNLPServer is running on http://localhost:9000....

import CoreNLP, { Properties, Pipeline } from 'corenlp';

const props = new Properties({
  annotators: 'tokenize,ssplit,pos,lemma,ner,parse',
});
const pipeline = new Pipeline(props, 'English'); // uses ConnectorServer by default

const sent = new CoreNLP.simple.Sentence('The little dog runs so fast.');
pipeline.annotate(sent)
  .then(sent => {
    console.log('parse', sent.parse());
    console.log(CoreNLP.util.Tree.fromSentence(sent).dump());
  })
  .catch(err => {
    console.log('err', err);
  });

API

Read the full API documentation.

Setup

1. Install the package:

npm i --save corenlp

2. Download Stanford CoreNLP

2.1. Shortcut (recommended to give this library a first try)

Via npm, run this command from your own project after having installed this library:

npm explore corenlp -- npm run corenlp:download

Once downloaded you can easily start the server by running

npm explore corenlp -- npm run corenlp:server

Or you can manually download the project from the Stanford's CoreNLP download section at: https://stanfordnlp.github.io/CoreNLP/download.html You may want to download, apart of the full package, other language models (see more on that page).

2.2. Via sources

For advanced projects, when you have to customize the library a bit more, we highly recommend to download the StanfordCoreNLP from the original repository, and compile the source code by using ant jar.

NOTE: Some functionality included in this library, for TokensRegex, Semgrex and Tregex, requires the latest version from that repository, which contains some fixes needed by this library, not included in the latest stable release.

3. Configure Stanford CoreNLP

There are two method to connect your NodeJS application to Stanford CoreNLP:

  1. HTTP is the preferred method since it requires CoreNLP to initialize just once to serve many requests, it also avoids extra I/O given that the CLI method need to write temporary files to run recommended.
  2. Via Command Line Interface, this is by spawning processes from your app.

3.1. Using StanfordCoreNLPServer

# Run the server using all jars in the current directory (e.g., the CoreNLP home directory)
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000

CoreNLP connects by default via StanfordCoreNLPServer, using port 9000. You can also opt to setup the connection differently:

import CoreNLP, { Properties, Pipeline, ConnectorServer } from 'corenlp';

const connector = new ConnectorServer({ dsn: 'http://localhost:9000' });
const props = new Properties({
  annotators: 'tokenize,ssplit,pos,lemma,ner,parse',
});
const pipeline = new Pipeline(props, 'English', connector);

3.2. Use CoreNLP via CLI

CoreNLP expects by default the StanfordCoreNLP package to be placed (unzipped) inside the path ${YOUR_NPM_PROJECT_ROOT}/corenlp/. You can also opt to setup the CLI interface differently:

import CoreNLP, { Properties, Pipeline, ConnectorCli } from 'corenlp';

const connector = new ConnectorCli({
  classPath: 'corenlp/stanford-corenlp-full-2017-06-09/*', // specify the paths relative to your npm project root
  mainClass: 'edu.stanford.nlp.pipeline.StanfordCoreNLP', // optional
  props: 'StanfordCoreNLP-spanish.properties', // optional
});
const props = new Properties({
  annotators: 'tokenize,ssplit,pos,lemma,ner,parse',
});
const pipeline = new Pipeline(props, 'English', connector);

4. Usage

4.1 Pipeline

// ... include dependencies

const props = new Properties({ annotators: 'tokenize,ssplit,lemma,pos,ner' });
const pipeline = new Pipeline(props, 'English', connector);
const sent = new CoreNLP.simple.Sentence('Hello world');
pipeline.annotate(sent)
  .then(sent => {
    console.log(sent.words());
    console.log(sent.nerTags());
  })
  .catch(err => {
    console.log('err', err);
  });

4.2 Penn TreeBank traversing

// ... include dependencies

const props = new Properties();
props.setProperty('annotators', 'tokenize,ssplit,pos,lemma,ner,parse');
const pipeline = new Pipeline(props, 'Spanish');

const sent = new CoreNLP.simple.Sentence('Jorge quiere cinco empanadas de queso y carne.');
pipeline.annotate(sent)
  .then(sent => {
    console.log('parse', sent.parse()); // constituency parsing string representation
    const tree = CoreNLP.util.Tree.fromSentence(sent);
    tree.visitLeaves(node =>
      console.log(node.word(), node.pos(), node.token().ner()));
    console.log(tree.dump());
  })
  .catch(err => {
    console.log('err', err);
  });

4.3 TokensRegex, Tregex and Semgrex

// ... include dependencies

const props = new Properties();
props.setProperty('annotators', 'tokenize,ssplit,regexner,depparse');
const expression = new CoreNLP.simple.Expression(
  'John Snow eats snow.',
  '{ner:PERSON}=who <nsubj ({pos:VBZ}=action >dobj {}=what)');
const pipeline = new Pipeline(props, 'English');

pipeline.annotateSemgrex(expression, true)  // similarly use pipeline.annotateTokensRegex / pipeline.annotateTregex
  .then(expression => expression.sentence(0).matches().map(match => {
      console.log('match', match.group('who'), match.group('action'), match.group('what'));
  }))
  .catch(err => {
    console.log('err', err);
  });

5. Client Side

This library is isomorphic, which means that works as well on a Browser. The API is exactly the same, and you can use it directly by requiring it via a <script> tag, using AMD (RequireJS), or within your app bundle.

The browser ready version of corenlp can be found as dist/index.browser.min.js, once built (npm run build).

See the examples folder for more details.

6. External Documentation

Properties
Pipeline
Service
ConnectorServer                   # https://stanfordnlp.github.io/CoreNLP/corenlp-server.html
ConnectorCli                      # https://stanfordnlp.github.io/CoreNLP/cmdline.html
CoreNLP
  simple                          # https://stanfordnlp.github.io/CoreNLP/simple.html
    Annotable
    Annotator
    Document
    Sentence
    Token
    annotator                     # https://stanfordnlp.github.io/CoreNLP/annotators.html
      TokenizerAnnotator          # https://stanfordnlp.github.io/CoreNLP/tokenize.html
      WordsToSentenceAnnotator    # https://stanfordnlp.github.io/CoreNLP/ssplit.html
      POSTaggerAnnotator          # https://stanfordnlp.github.io/CoreNLP/pos.html
      MorphaAnnotator             # https://stanfordnlp.github.io/CoreNLP/lemma.html
      NERClassifierCombiner       # https://stanfordnlp.github.io/CoreNLP/ner.html
      ParserAnnotator             # https://stanfordnlp.github.io/CoreNLP/parse.html
      DependencyParseAnnotator    # https://stanfordnlp.github.io/CoreNLP/depparse.html
      RelationExtractorAnnotator  # https://stanfordnlp.github.io/CoreNLP/relation.html
      CorefAnnotator              # https://stanfordnlp.github.io/CoreNLP/coref.html
      SentimentAnnotator          # https://stanfordnlp.github.io/CoreNLP/sentiment.html - Comming soon...
      RelationExtractorAnnotator  # https://stanfordnlp.github.io/CoreNLP/relation.html - TODO
      NaturalLogicAnnotator       # https://stanfordnlp.github.io/CoreNLP/natlog.html - TODO
      QuoteAnnotator              # https://stanfordnlp.github.io/CoreNLP/quote.html - TODO
  util
    Tree                          # http://www.cs.cornell.edu/courses/cs474/2004fa/lec1.pdf

7. References

This library is not maintained by StanfordNLP. However, it's based on and depends on StanfordNLP/CoreNLP to function.

Manning, Christopher D., Mihai Surdeanu, John Bauer, Jenny Finkel, Steven J. Bethard, and David McClosky. 2014. The Stanford CoreNLP Natural Language Processing Toolkit In Proceedings of the 52nd Annual Meeting of the Association for Computational Linguistics: System Demonstrations, pp. 55-60.

node-corenlp's People

Contributors

curiousite avatar ehacke avatar gerardobort avatar kmanzana avatar rtsao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-corenlp's Issues

Properties not forwarded to server?

Hi,

I'm trying to set a property to the ssplit with the following code:

const props = new corenlp.Properties({
  annotators: 'tokenize,ssplit',
});
props.setProperty('ssplit.newlineIsSentenceBreak', 'always');

But the property is being ignored during processing, is there any reason for this? Do you know if this is supported?

Adding 'sentiment' to annotators throws an exception

I am not sure if sentiment analysis is supported by corenlp.

`var nlp = require("corenlp").default;
var prop = require("./../node_modules/corenlp/dist/properties");
var pipe = require("./../node_modules/corenlp/dist/pipeline");
var sentence = require("./../node_modules/corenlp/dist/simple/sentence");
var tree = require("./../node_modules/corenlp/dist/util/tree");

const props = new prop.Properties({
annotators: 'tokenize,ssplit,pos,lemma,ner,parse, sentiment',
});
const pipeline = new pipe.Pipeline(props, 'English'); // uses ConnectorServer by default

const sent = new sentence.Sentence('The little dog runs so fast.');
pipeline.annotate(sent)
.then(sent => {
console.log('parse', sent.parse());
console.log(tree.Tree.fromSentence(sent).dump());
})
.catch(err => {
console.log('err', err);
});`

ERROR:

err TypeError: Cannot read property 'toString' of undefined at Sentence.addAnnotator (/home/ubuntu/workspace/sentiment-analyzer/node_modules/corenlp/dist/simple/annotable.js:72:33) at /home/ubuntu/workspace/sentiment-analyzer/node_modules/corenlp/dist/simple/annotable.js:86:22 at Array.forEach (native) at Sentence.addAnnotators (/home/ubuntu/workspace/sentiment-analyzer/node_modules/corenlp/dist/simple/annotable.js:85:18) at Pipeline._callee$ (/home/ubuntu/workspace/sentiment-analyzer/node_modules/corenlp/dist/pipeline.js:156:27) at tryCatch (/home/ubuntu/workspace/sentiment-analyzer/node_modules/regenerator-runtime/runtime.js:65:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/home/ubuntu/workspace/sentiment-analyzer/node_modules/regenerator-runtime/runtime.js:303:22) at GeneratorFunctionPrototype.prototype.forEach.prototype.(anonymous function) [as next] (/home/ubuntu/workspace/sentiment-analyzer/node_modules/regenerator-runtime/runtime.js:117:21) at step (/home/ubuntu/workspace/sentiment-analyzer/node_modules/corenlp/dist/pipeline.js:71:191) at /home/ubuntu/workspace/sentiment-analyzer/node_modules/corenlp/dist/pipeline.js:71:361

How to pass regexner

How to pass my own regexner training data to server?

I am doing as below but it not shows my NER can you please provide some Example
I would like to identify martendail as MATERIAL

node file
require("babel-polyfill");
const corenlp = require("corenlp");
const CoreNLP = corenlp.default; // convenient when not using import

const connector = new corenlp.ConnectorServer({
dsn: 'http://localhost:9000',
});

const props = new corenlp.Properties();
props.setProperty('annotators', 'tokenize, ssplit, pos, lemma, parse, ner, regexner');
props.setProperty('regexner.mapping', 'training.txt');

const pipeline = new corenlp.Pipeline(props, 'English', connector);
const sent = new CoreNLP.simple.Sentence(
'martendail 20000 Julia Eileen Gillard (born 29 September 1961) is an Australian politician who was the Prime Minister of Australia.'
);

async function f(){
// performs the call to corenlp (in this case via http)
await pipeline.annotate(sent);

// constituency parse tree representation
const tree = CoreNLP.util.Tree.fromSentence(sent);

// traverse the tree leaves and print some props
tree.visitLeaves(node =>
  console.log(node.word(), node.token().ner()));

}

process.on('unhandledRejection', error => {
console.log('unhandledRejection', error.message);
});

f();

output

martendail O
20000 NUMBER
Julia PERSON
Eileen PERSON
Gillard PERSON
-LRB- O
born O
29 DATE
September DATE
1961 DATE
-RRB- O
is O
an O
Australian NATIONALITY
politician TITLE
who O
was O
the O
Prime TITLE
Minister TITLE
of O
Australia COUNTRY

training.txt

( /martendail/ ) MATERIAL
( /martendail/ [ner:NUMBER] ) MATERIAL

Syntax error

I have been trying to run corenlp in my Cloud9 Ubuntu environment inside an Express.Js web app for the last couple of hours in vain. I copied and pasted the code in example but it says 'import' is not a valid syntax. So I tried this:

`//import CoreNLP, { Properties, Pipeline } from 'corenlp';
var nlp = require("corenlp");

const props = new nlp.Properties({
annotators: 'tokenize,ssplit,pos,lemma,ner,parse',
});
const pipeline = new nlp.Pipeline(props, 'English'); // uses ConnectorServer by default

const sent = new nlp.simple.Sentence('The little dog runs so fast.');
pipeline.annotate(sent)
.then(sent => {
console.log('parse', sent.parse());
console.log(nlp.CoreNLP.util.Tree.fromSentence(sent).dump());
})
.catch(err => {
console.log('err', err);
});`
I know I am doing this wrong but I could not find any help anywhere! Forced to come here and open and issue. Any help is appreciated.

P.S The Stanford NLP server is running at Port:9000

Add type definitions for usage with typescript projects

I extracted the types from jsdocs using a template "tsd-jsdoc" & made some changes. The namespace had to be renamed & rearranged.
The following code works for me Hope its gonna help others.

// jsdoc node_modules/corenlp/dist/ -t node_modules/tsd-jsdoc/dist -r
/**
 * @class
 * @classdesc Class representing a Connector CLI (command line interface client)
 */
export class ConnectorCli {
    constructor(config: {
        classPath: string;
        mainClass: string;
        props: string;
    });
    /**
     * @returns {Promise<Object>}
     */
    get(): Promise<any>;
    /**
     * @returns {Promise<Object>}
     */
    get(): Promise<any>;
}

/**
 * @class
 * @classdesc Class representing a Connector Server (web server client)
 */
export class ConnectorServer {
    constructor(config: {
        dsn: string;
        username?: string;
        // username?: string;
    });
    /**
     * @param {Object} config
     * @param {Array.<string>} config.annotators - The list of annotators that defines the pipeline
     * @param {string} config.text - The text to run the pipeline against
     * @param {Object} config.options - Additinal options (properties) for the pipeline
     * @param {string} config.language - Language full name in CamelCase (eg. Spanish)
     * @param {(''|'tokensregex'|'semgrex'|'tregex')} [utility] - Name of the utility to use
     * NOTE: most of the utilities receives properties, these should be passed via the options param
     * @returns {Promise<Object>}
     */
    get(config: {
        annotators: string[];
        text: string;
        options: any;
        language: string;
    }, utility?: '' | 'tokensregex' | 'semgrex' | 'tregex'): Promise<any>;
    /**
     * @param {Object} config
     * @param {Array.<string>} config.annotators - The list of annotators that defines the pipeline
     * @param {string} config.text - The text to run the pipeline against
     * @param {Object} config.options - Additinal options (properties) for the pipeline
     * @param {string} config.language - Language full name in CamelCase (eg. Spanish)
     * @param {(''|'tokensregex'|'semgrex'|'tregex')} [utility] - Name of the utility to use
     * NOTE: most of the utilities receives properties, these should be passed via the options param
     * @returns {Promise<Object>}
     */
    get(config: {
        annotators: string[];
        text: string;
        options: any;
        language: string;
    }, utility?: '' | 'tokensregex' | 'semgrex' | 'tregex'): Promise<any>;
}

export namespace CoreNLP {
    /**
     * @namespace CoreNLP/simple
     * @description NodeJS API that emulates {@link https://stanfordnlp.github.io/CoreNLP/simple.html}
     */
    namespace simple {
        /**
         * @class
         * @classdesc Class representing an Annotable
         * @memberof CoreNLP/simple
         */
        class Annotable {
            constructor(text: string);
            /**
             * Get a string representation of the raw text
             * @return {string} text
             */
            text(): string;
            /**
             * Sets the language ISO (given by the pipeline during the annotation process)
             * This is solely to keep track of the language chosen for further analysis
             * The language string should be passed in lowercase ISO2 format
             * @return {string} text
             */
            setLanguageISO(): string;
            /**
             * Retrieves the language ISO (in lowercase ISO2 format)
             * @return {string} iso
             */
            getLanguageISO(): string;
            /**
             * Marks an annotator as a met dependency
             * @param {Annotator|function} annotator
             */
            addAnnotator(annotator: Annotator | ((...params: any[]) => any)): void;
            /**
             * Marks multiple annotators as a met dependencies
             * @param {Array.<Annotator|function>} annotators
             */
            addAnnotators(annotators: (Annotator | ((...params: any[]) => any))[]): void;
            /**
             * Unmarks an annotator as a met dependency
             * @param {Annotator|function} annotator
             */
            removeAnnotator(annotator: Annotator | ((...params: any[]) => any)): void;
            /**
             * Tells you if an annotator is a met dependency
             * @param {Annotator|function} annotator
             * @returns {boolean} hasAnnotator
             */
            hasAnnotator(annotator: Annotator | ((...params: any[]) => any)): boolean;
            /**
             * Tells you if at least on of a list of annotators is a met dependency
             * @param {Array.<Annotator|function>} annotators
             * @returns {boolean} hasAnyAnnotator
             */
            hasAnyAnnotator(annotators: (Annotator | ((...params: any[]) => any))[]): boolean;
            /**
             * Get a string representation of the raw text
             * @return {string} text
             */
            text(): string;
            /**
             * Sets the language ISO (given by the pipeline during the annotation process)
             * This is solely to keep track of the language chosen for further analysis
             * The language string should be passed in lowercase ISO2 format
             * @return {string} text
             */
            setLanguageISO(): string;
            /**
             * Retrieves the language ISO (in lowercase ISO2 format)
             * @return {string} iso
             */
            getLanguageISO(): string;
            /**
             * Marks an annotator as a met dependency
             * @param {Annotator|function} annotator
             */
            addAnnotator(annotator: Annotator | ((...params: any[]) => any)): void;
            /**
             * Marks multiple annotators as a met dependencies
             * @param {Array.<Annotator|function>} annotators
             */
            addAnnotators(annotators: (Annotator | ((...params: any[]) => any))[]): void;
            /**
             * Unmarks an annotator as a met dependency
             * @param {Annotator|function} annotator
             */
            removeAnnotator(annotator: Annotator | ((...params: any[]) => any)): void;
            /**
             * Tells you if an annotator is a met dependency
             * @param {Annotator|function} annotator
             * @returns {boolean} hasAnnotator
             */
            hasAnnotator(annotator: Annotator | ((...params: any[]) => any)): boolean;
            /**
             * Tells you if at least on of a list of annotators is a met dependency
             * @param {Array.<Annotator|function>} annotators
             * @returns {boolean} hasAnyAnnotator
             */
            hasAnyAnnotator(annotators: (Annotator | ((...params: any[]) => any))[]): boolean;
        }
        /**
         * @class
         * @classdesc Class representing an Annotatror
         * @memberof CoreNLP/simple
         */
        class Annotator {
            constructor(name: string, options?: any, dependencies?: Annotator[]);
            /**
             * Get a string representation
             * @return {string} annotator
             */
            toString(): string;
            /**
             * Defines whether a given annotator is the same as current, using shallow compare.
             * This is useful for a Document or Sentence to validate if the minimum of annotators required
             * were already applied to them.  Allows at the same time the users to instantiate new annotators
             * and configure them as needed.
             * @param {Annotator} annotator
             * @return {boolean}
             */
            equalsTo(annotator: Annotator): boolean;
            /**
             * Get an Object key-value representation of the annotor's options (excluding prefix)
             * @return {Object} options
             */
            options(): any;
            /**
             * Get/Set an option value
             * @param {string} key
             * @param {string|boolean} [value]
             * @return {string} value
             */
            option(key: string, value?: string | boolean): string;
            /**
             * Get a list of annotators dependencies
             * @return {Array.<Annotator>} dependencies
             */
            dependencies(): Annotator[];
            /**
             * Get a list of annotators dependencies, following by this annotator, all this as
             * a list of strings
             * This is useful to fulfill the 'annotators' param in CoreNLP API properties.
             * @return {Array.<string>} pipeline
             */
            pipeline(): string[];
            /**
             * Get an object of all the Annotator options including the current and all its
             * dependencies, prefixed by the annotator names
             * This is useful to fulfill the options params in CoreNLP API properties.
             * @return {Array.<string>} pipelineOptions
             */
            pipelineOptions(): string[];
            /**
             * Get a string representation
             * @return {string} annotator
             */
            toString(): string;
            /**
             * Defines whether a given annotator is the same as current, using shallow compare.
             * This is useful for a Document or Sentence to validate if the minimum of annotators required
             * were already applied to them.  Allows at the same time the users to instantiate new annotators
             * and configure them as needed.
             * @param {Annotator} annotator
             * @return {boolean}
             */
            equalsTo(annotator: Annotator): boolean;
            /**
             * Get an Object key-value representation of the annotor's options (excluding prefix)
             * @return {Object} options
             */
            options(): any;
            /**
             * Get/Set an option value
             * @param {string} key
             * @param {string|boolean} [value]
             * @return {string} value
             */
            option(key: string, value?: string | boolean): string;
            /**
             * Get a list of annotators dependencies
             * @return {Array.<Annotator>} dependencies
             */
            dependencies(): Annotator[];
            /**
             * Get a list of annotators dependencies, following by this annotator, all this as
             * a list of strings
             * This is useful to fulfill the 'annotators' param in CoreNLP API properties.
             * @return {Array.<string>} pipeline
             */
            pipeline(): string[];
            /**
             * Get an object of all the Annotator options including the current and all its
             * dependencies, prefixed by the annotator names
             * This is useful to fulfill the options params in CoreNLP API properties.
             * @return {Array.<string>} pipelineOptions
             */
            pipelineOptions(): string[];
        }
        /**
         * @class
         * @classdesc Class representing a Document
         * @extends Annotable
         * @memberof CoreNLP/simple
         */
        class Document extends Annotable {
            constructor(text: string);
            /**
             * Get a string representation
             * @return {string} document
             */
            toString(): string;
            /**
             * Get a list of sentences
             * @returns {Array.<Sentence>} sentences - The document sentences
             */
            sentences(): Sentence[];
            /**
             * Get the sentence for a given index
             * @param {number} index - The position of the sentence to get
             * @returns {Sentence} sentence - The document sentences
             */
            sentence(index: number): Sentence;
            /**
             * @todo Missing implementation
             * @see https://stanfordnlp.github.io/CoreNLP/dcoref.html
             * @returns {Array.<CorefChain>}
             */
            corefs(): CorefChain[];
            /**
             * Get the coreference for a given index
             * @param {number} index - 0-based index of the coref chain list
             * @see https://stanfordnlp.github.io/CoreNLP/dcoref.html
             * @returns {CorefChain}
             */
            coref(index: number): CorefChain;
            /**
             * Sets the language ISO (given by the pipeline during the annotation process)
             * This is solely to keep track of the language chosen for further analysis
             * @return {string} text
             */
            setLanguageISO(): string;
            /**
             * Update an instance of Document with data provided by a JSON
             * @param {DocumentJSON} data - The document data, as returned by CoreNLP API service
             * @returns {Document} document - The current document instance
             */
            fromJSON(data: DocumentJSON): Document;
            /**
             * Get an instance of Document from a given JSON
             * @param {DocumentJSON} data - The document data, as returned by CoreNLP API service
             * @returns {Document} document - A new Document instance
             */
            static fromJSON(data: DocumentJSON): Document;
            /**
             * Get a string representation
             * @return {string} document
             */
            toString(): string;
            /**
             * Get a list of sentences
             * @returns {Array.<Sentence>} sentences - The document sentences
             */
            sentences(): Sentence[];
            /**
             * Get the sentence for a given index
             * @param {number} index - The position of the sentence to get
             * @returns {Sentence} sentence - The document sentences
             */
            sentence(index: number): Sentence;
            /**
             * @todo Missing implementation
             * @see https://stanfordnlp.github.io/CoreNLP/dcoref.html
             * @returns {Array.<CorefChain>}
             */
            corefs(): CorefChain[];
            /**
             * Get the coreference for a given index
             * @param {number} index - 0-based index of the coref chain list
             * @see https://stanfordnlp.github.io/CoreNLP/dcoref.html
             * @returns {CorefChain}
             */
            coref(index: number): CorefChain;
            /**
             * Sets the language ISO (given by the pipeline during the annotation process)
             * This is solely to keep track of the language chosen for further analysis
             * @return {string} text
             */
            setLanguageISO(): string;
            /**
             * Update an instance of Document with data provided by a JSON
             * @param {DocumentJSON} data - The document data, as returned by CoreNLP API service
             * @returns {Document} document - The current document instance
             */
            fromJSON(data: DocumentJSON): Document;
            /**
             * Get an instance of Document from a given JSON
             * @param {DocumentJSON} data - The document data, as returned by CoreNLP API service
             * @returns {Document} document - A new Document instance
             */
            static fromJSON(data: DocumentJSON): Document;
        }
        /**
         * @class
         * @classdesc Class representing an Expression
         * @extends Annotable
         * @memberof CoreNLP/simple
         */
        class Expression extends Annotable {
            constructor(text: string, pattern: string);
            /**
             * Get a string representation
             * @return {string} expression
             */
            toString(): string;
            /**
             * Get the pattern
             * @returns {string} pattern - The expression pattern
             */
            pattern(): string;
            /**
             * Get a list of sentences
             * @returns {Array.<ExpressionSentence>} sentences - The expression sentences
             */
            sentences(): ExpressionSentence[];
            /**
             * Get the sentence for a given index
             * @param {number} index - The position of the sentence to get
             * @returns {ExpressionSentence} sentence - An expression sentence
             */
            sentence(index: number): ExpressionSentence;
            /**
             * Hydrate the Expression instance with Token objects from an annotated Document
             * @see {@link ExpressionSentence#mergeTokensFromSentence}
             * @param {Document} document - An annotated document from where to extract the tokens
             * @returns {Expression} expression - The current expression instance
             */
            mergeTokensFromDocument(document: Document): Expression;
            /**
             * Update an instance of Expression with data provided by a JSON
             * @param {ExpressionJSON} data - The expression data, as returned by CoreNLP API service
             * @returns {Expression} expression - The current expression instance
             */
            fromJSON(data: ExpressionJSON): Expression;
            /**
             * Get an instance of Expression from a given JSON
             * @param {ExpressionJSON} data - The expression data, as returned by CoreNLP API service
             * @returns {Expression} expression - A new Expression instance
             */
            static fromJSON(data: ExpressionJSON): Expression;
            /**
             * Get a string representation
             * @return {string} expression
             */
            toString(): string;
            /**
             * Get the pattern
             * @returns {string} pattern - The expression pattern
             */
            pattern(): string;
            /**
             * Get a list of sentences
             * @returns {Array.<ExpressionSentence>} sentences - The expression sentences
             */
            sentences(): ExpressionSentence[];
            /**
             * Get the sentence for a given index
             * @param {number} index - The position of the sentence to get
             * @returns {ExpressionSentence} sentence - An expression sentence
             */
            sentence(index: number): ExpressionSentence;
            /**
             * Hydrate the Expression instance with Token objects from an annotated Document
             * @see {@link ExpressionSentence#mergeTokensFromSentence}
             * @param {Document} document - An annotated document from where to extract the tokens
             * @returns {Expression} expression - The current expression instance
             */
            mergeTokensFromDocument(document: Document): Expression;
            /**
             * Update an instance of Expression with data provided by a JSON
             * @param {ExpressionJSON} data - The expression data, as returned by CoreNLP API service
             * @returns {Expression} expression - The current expression instance
             */
            fromJSON(data: ExpressionJSON): Expression;
            /**
             * Get an instance of Expression from a given JSON
             * @param {ExpressionJSON} data - The expression data, as returned by CoreNLP API service
             * @returns {Expression} expression - A new Expression instance
             */
            static fromJSON(data: ExpressionJSON): Expression;
        }
        /**
         * @class
         * @classdesc Class representing a Governor
         * @memberof CoreNLP/simple
         */
        class Governor {
            constructor(dep: string, dependentToken: Token, governorToken?: Token);
            /**
             * Get a string representation
             * @return {string} governor
             */
            toString(): string;
            /**
             * Get an instance of Governor from a given JSON
             *
             * @todo It is not possible to properly generate a Governor from a GovernorJSON
             *       the Governor requires references to the Token instances in order to work
             * @param {GovernorJSON} data - The token data, as returned by CoreNLP API service
             * @returns {Governor} governor - A new Governor instance
             */
            static fromJSON(data: GovernorJSON): Governor;
            /**
             * Get a string representation
             * @return {string} governor
             */
            toString(): string;
            /**
             * Get an instance of Governor from a given JSON
             *
             * @todo It is not possible to properly generate a Governor from a GovernorJSON
             *       the Governor requires references to the Token instances in order to work
             * @param {GovernorJSON} data - The token data, as returned by CoreNLP API service
             * @returns {Governor} governor - A new Governor instance
             */
            static fromJSON(data: GovernorJSON): Governor;
        }
        /**
         * @class
         * @classdesc Class representing a Sentence
         * @extends Annotable
         * @memberof CoreNLP/simple
         * @see {@link https://github.com/stanfordnlp/CoreNLP/blob/master/src/edu/stanford/nlp/simple/Sentence.java}
         */
        class Sentence extends Annotable {
            constructor(text: string);
            /**
             * Get a string representation
             * @returns {string} sentence
             */
            toString(): string;
            /**
             * Get the index relative to the parent document
             * @returns {number} index
             */
            index(): number;
            /**
             * Get a string representation of the parse tree structure
             * @returns {string} parse
             */
            parse(): string;
            /**
             * Get an array of string representations of the sentence words
             * @requires {@link TokenizerAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @returns {Array.<string>} words
             */
            words(): string[];
            /**
             * Get a string representations of the Nth word of the sentence
             * @requires {@link TokenizerAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @throws {Error} in case the token for the given index does not exists
             * @param {number} index - 0-based index as they are arranged naturally
             * @returns {string} word
             */
            word(index: number): string;
            /**
             * Get a string representations of the tokens part of speech of the sentence
             * @returns {Array.<string>} posTags
             */
            posTags(): string[];
            /**
             * Get a string representations of the Nth token part of speech of the sentence
             * @throws {Error} in case the token for the given index does not exists
             * @param {number} index - 0-based index as they are arranged naturally
             * @returns {string} posTag
             */
            posTag(index: number): string;
            /**
             * Get a string representations of the tokens lemmas of the sentence
             * @returns {Array.<string>} lemmas
             */
            lemmas(): string[];
            /**
             * Get a string representations of the Nth token lemma of the sentence
             * @throws {Error} in case the token for the given index does not exists
             * @param {number} index - 0-based index as they are arranged naturally
             * @returns {string} lemma
             */
            lemma(index: number): string;
            /**
             * Get a string representations of the tokens nerTags of the sentence
             * @returns {Array.<string>} nerTags
             */
            nerTags(): string[];
            /**
             * Get a string representations of the Nth token nerTag of the sentence
             * @throws {Error} in case the token for the given index does not exists
             * @param {number} index - 0-based index as they are arranged naturally
             * @returns {string} nerTag
             */
            nerTag(index: number): string;
            /**
             * Get a list of annotated governors by the dependency-parser
             * @requires {@link DependencyParseAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @returns {Array.<Governor>} governors
             */
            governors(): Governor[];
            /**
             * Get the N-th annotated governor by the dependency-parser annotator
             * @requires {@link DependencyParseAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @returns {Governor} governor
             */
            governor(): Governor;
            /**
             * Get an array of token representations of the sentence words
             * @requires {@link TokenizerAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @returns {Array.<Token>} tokens
             */
            tokens(): Token[];
            /**
             * Get the Nth token of the sentence
             * @requires {@link TokenizerAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @returns {Token} token
             */
            token(): Token;
            /**
             * Sets the language ISO (given by the pipeline during the annotation process)
             * This is solely to keep track of the language chosen for further analysis
             * @return {string} text
             */
            setLanguageISO(): string;
            /**
             * Get a JSON representation of the current sentence
             * @description
             * The following arrow function 'data => Sentence.fromJSON(data).toJSON()' is idempontent, if
             * considering shallow comparison, not by reference.
             * This JSON will respects the same structure as it expects from {@see Sentence#fromJSON}.
             * @returns {SentenceJSON} data
             */
            toJSON(): SentenceJSON;
            /**
             * Update an instance of Sentence with data provided by a JSON
             * @param {SentenceJSON} data - The document data, as returned by CoreNLP API service
             * @param {boolean} [isSentence] - Indicate if the given data represents just the sentence
             * or a full document with just a sentence inside
             * @returns {Sentence} sentence - The current sentence instance
             */
            fromJSON(data: SentenceJSON, isSentence?: boolean): Sentence;
            /**
             * Get an instance of Sentence from a given JSON
             * @param {SentenceJSON} data - The document data, as returned by CoreNLP API service
             * @param {boolean} [isSentence] - Indicate if the given data represents just the sentence of a
             * full document
             * @returns {Sentence} document - A new Sentence instance
             */
            static fromJSON(data: SentenceJSON, isSentence?: boolean): Sentence;
            /**
             * Get a string representation
             * @returns {string} sentence
             */
            toString(): string;
            /**
             * Get the index relative to the parent document
             * @returns {number} index
             */
            index(): number;
            /**
             * Get a string representation of the parse tree structure
             * @returns {string} parse
             */
            parse(): string;
            /**
             * Get an array of string representations of the sentence words
             * @requires {@link TokenizerAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @returns {Array.<string>} words
             */
            words(): string[];
            /**
             * Get a string representations of the Nth word of the sentence
             * @requires {@link TokenizerAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @throws {Error} in case the token for the given index does not exists
             * @param {number} index - 0-based index as they are arranged naturally
             * @returns {string} word
             */
            word(index: number): string;
            /**
             * Get a string representations of the tokens part of speech of the sentence
             * @returns {Array.<string>} posTags
             */
            posTags(): string[];
            /**
             * Get a string representations of the Nth token part of speech of the sentence
             * @throws {Error} in case the token for the given index does not exists
             * @param {number} index - 0-based index as they are arranged naturally
             * @returns {string} posTag
             */
            posTag(index: number): string;
            /**
             * Get a string representations of the tokens lemmas of the sentence
             * @returns {Array.<string>} lemmas
             */
            lemmas(): string[];
            /**
             * Get a string representations of the Nth token lemma of the sentence
             * @throws {Error} in case the token for the given index does not exists
             * @param {number} index - 0-based index as they are arranged naturally
             * @returns {string} lemma
             */
            lemma(index: number): string;
            /**
             * Get a string representations of the tokens nerTags of the sentence
             * @returns {Array.<string>} nerTags
             */
            nerTags(): string[];
            /**
             * Get a string representations of the Nth token nerTag of the sentence
             * @throws {Error} in case the token for the given index does not exists
             * @param {number} index - 0-based index as they are arranged naturally
             * @returns {string} nerTag
             */
            nerTag(index: number): string;
            /**
             * Get a list of annotated governors by the dependency-parser
             * @requires {@link DependencyParseAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @returns {Array.<Governor>} governors
             */
            governors(): Governor[];
            /**
             * Get the N-th annotated governor by the dependency-parser annotator
             * @requires {@link DependencyParseAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @returns {Governor} governor
             */
            governor(): Governor;
            /**
             * Get an array of token representations of the sentence words
             * @requires {@link TokenizerAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @returns {Array.<Token>} tokens
             */
            tokens(): Token[];
            /**
             * Get the Nth token of the sentence
             * @requires {@link TokenizerAnnotator}
             * @throws {Error} in case the require annotator was not applied to the sentence
             * @returns {Token} token
             */
            token(): Token;
            /**
             * Sets the language ISO (given by the pipeline during the annotation process)
             * This is solely to keep track of the language chosen for further analysis
             * @return {string} text
             */
            setLanguageISO(): string;
            /**
             * Get a JSON representation of the current sentence
             * @description
             * The following arrow function 'data => Sentence.fromJSON(data).toJSON()' is idempontent, if
             * considering shallow comparison, not by reference.
             * This JSON will respects the same structure as it expects from {@see Sentence#fromJSON}.
             * @returns {SentenceJSON} data
             */
            toJSON(): SentenceJSON;
            /**
             * Update an instance of Sentence with data provided by a JSON
             * @param {SentenceJSON} data - The document data, as returned by CoreNLP API service
             * @param {boolean} [isSentence] - Indicate if the given data represents just the sentence
             * or a full document with just a sentence inside
             * @returns {Sentence} sentence - The current sentence instance
             */
            fromJSON(data: SentenceJSON, isSentence?: boolean): Sentence;
            /**
             * Get an instance of Sentence from a given JSON
             * @param {SentenceJSON} data - The document data, as returned by CoreNLP API service
             * @param {boolean} [isSentence] - Indicate if the given data represents just the sentence of a
             * full document
             * @returns {Sentence} document - A new Sentence instance
             */
            static fromJSON(data: SentenceJSON, isSentence?: boolean): Sentence;
        }
        /**
         * @class
         * @classdesc Class representing a Token
         * @extends Annotable
         * @memberof CoreNLP/simple
         */
        class Token extends Annotable {
            constructor(word: string);
            /**
             * Get a string representation
             * @returns {string} token
             */
            toString(): string;
            /**
             * Get the 'inde ' number associated by the StanfordCoreNLP
             * This index is relative to the sentence it belongs to, and is a 1-based (possitive integer).
             * This number is useful to match tokens within a sentence for depparse, coreference, etc.
             * @returns {number} index
             */
            index(): number;
            /**
             * Get the original word
             * @returns {string} word
             */
            word(): string;
            /**
             * Get the original text
             * @returns {string} originalText
             */
            originalText(): string;
            /**
             * Get the characterOffsetBegin relative to the parent sentence
             * @description
             * A 0-based index of the word's initial character within the sentence
             * @returns {number} characterOffsetBegin
             */
            characterOffsetBegin(): number;
            /**
             * Get the characterOffsetEnd relative to the parent sentence
             * A 0-based index of the word's ending character within the sentence
             * @returns {number} characterOffsetEnd
             */
            characterOffsetEnd(): number;
            /**
             * Get the 'before' string relative to the container sentence
             * @returns {string} before
             */
            before(): string;
            /**
             * Get the 'after' string relative to the container sentence
             * @returns {string} after
             */
            after(): string;
            /**
             * Get the annotated lemma
             * @returns {string} lemma
             */
            lemma(): string;
            /**
             * Get the annotated part-of-speech for the current token
             * @returns {string} pos
             */
            pos(): string;
            /**
             * Get additional metadata about the POS annotation
             * NOTE: Do not use this method other than just for study or analysis purposes.
             * @see {@link PosInfo} for more details
             * @returns {PosInfo} posInfo
             */
            posInfo(): PosInfo;
            /**
             * Get the annotated named-entity for the current token
             * @returns {string} ner
             */
            ner(): string;
            /**
             * Get the annotated speaker for the current token
             * @see {@link CorefAnnotator}
             * @returns {string} speaker
             */
            speaker(): string;
            /**
             * Get a JSON representation of the current token
             * @description
             * The following arrow function 'data => Token.fromJSON(data).toJSON()' is idempontent, if
             * considering shallow comparison, not by reference.
             * This JSON will respects the same structure as it expects from {@see Token#fromJSON}.
             * @returns {TokenJSON} data
             */
            toJSON(): TokenJSON;
            /**
             * Get an instance of Token from a given JSON
             * @param {TokenJSON} data - The token data, as returned by CoreNLP API service
             * @returns {Token} token - A new Token instance
             */
            static fromJSON(data: TokenJSON): Token;
            /**
             * Get a string representation
             * @returns {string} token
             */
            toString(): string;
            /**
             * Get the 'inde ' number associated by the StanfordCoreNLP
             * This index is relative to the sentence it belongs to, and is a 1-based (possitive integer).
             * This number is useful to match tokens within a sentence for depparse, coreference, etc.
             * @returns {number} index
             */
            index(): number;
            /**
             * Get the original word
             * @returns {string} word
             */
            word(): string;
            /**
             * Get the original text
             * @returns {string} originalText
             */
            originalText(): string;
            /**
             * Get the characterOffsetBegin relative to the parent sentence
             * @description
             * A 0-based index of the word's initial character within the sentence
             * @returns {number} characterOffsetBegin
             */
            characterOffsetBegin(): number;
            /**
             * Get the characterOffsetEnd relative to the parent sentence
             * A 0-based index of the word's ending character within the sentence
             * @returns {number} characterOffsetEnd
             */
            characterOffsetEnd(): number;
            /**
             * Get the 'before' string relative to the container sentence
             * @returns {string} before
             */
            before(): string;
            /**
             * Get the 'after' string relative to the container sentence
             * @returns {string} after
             */
            after(): string;
            /**
             * Get the annotated lemma
             * @returns {string} lemma
             */
            lemma(): string;
            /**
             * Get the annotated part-of-speech for the current token
             * @returns {string} pos
             */
            pos(): string;
            /**
             * Get additional metadata about the POS annotation
             * NOTE: Do not use this method other than just for study or analysis purposes.
             * @see {@link PosInfo} for more details
             * @returns {PosInfo} posInfo
             */
            posInfo(): PosInfo;
            /**
             * Get the annotated named-entity for the current token
             * @returns {string} ner
             */
            ner(): string;
            /**
             * Get the annotated speaker for the current token
             * @see {@link CorefAnnotator}
             * @returns {string} speaker
             */
            speaker(): string;
            /**
             * Get a JSON representation of the current token
             * @description
             * The following arrow function 'data => Token.fromJSON(data).toJSON()' is idempontent, if
             * considering shallow comparison, not by reference.
             * This JSON will respects the same structure as it expects from {@see Token#fromJSON}.
             * @returns {TokenJSON} data
             */
            toJSON(): TokenJSON;
            /**
             * Get an instance of Token from a given JSON
             * @param {TokenJSON} data - The token data, as returned by CoreNLP API service
             * @returns {Token} token - A new Token instance
             */
            static fromJSON(data: TokenJSON): Token;
        }
        
        /**
         * @namespace CoreNLP/simple/annotator
         * @description Predefined annotators {@link https://stanfordnlp.github.io/CoreNLP/annotators.html}
         */
        namespace annotator {
            /**
             * @class
             * @classdesc Class representing an CorefAnnotator.
             * @extends Annotator
             * @memberof CoreNLP/simple/annotator
             * @requires tokenize, ssplit, coref
             * @see {@link https://stanfordnlp.github.io/CoreNLP/coref.html|CorefAnnotator}
             */
            class CorefAnnotator extends Annotator {
                constructor(options?: any);
            }
            /**
             * @class
             * @classdesc Class representing an DependencyParseAnnotator. Hydrates {@link Sentence.governors()}
             * @extends Annotator
             * @memberof CoreNLP/simple/annotator
             * @requires tokenize, ssplit, pos, lemma, ner, parse, depparse
             * @see {@link https://stanfordnlp.github.io/CoreNLP/depparse.html|DependencyParseAnnotator}
             */
            class DependencyParseAnnotator extends Annotator {
                constructor(options?: any);
            }
            /**
             * @class
             * @classdesc Class representing an MorphaAnnotator. Hydrates {@link Token.lemma()}
             * @extends Annotator
             * @memberof CoreNLP/simple/annotator
             * @requires tokenize, ssplit, pos, lemma
             * @see {@link https://stanfordnlp.github.io/CoreNLP/lemma.html|MorphaAnnotator}
             */
            class MorphaAnnotator extends Annotator {
                constructor(options?: any);
            }
            /**
             * @class
             * @classdesc Class representing an NERClassifierCombiner. Hydrates {@link Token.ner()}
             * @extends Annotator
             * @memberof CoreNLP/simple/annotator
             * @requires tokenize, ssplit, pos, lemma, ner
             * @see {@link https://stanfordnlp.github.io/CoreNLP/ner.html|NERClassifierCombiner}
             */
            class NERClassifierCombiner extends Annotator {
                constructor(options?: any);
            }
            /**
             * @class
             * @class Class representing an ParserAnnotator. Hydrates {@link Token.parse()}
             * @extends Annotator
             * @memberof CoreNLP/simple/annotator
             * @requires tokenize, ssplit, pos, lemma, ner, parse
             * @see {@link https://stanfordnlp.github.io/CoreNLP/parse.html|ParserAnnotator}
             */
            class ParserAnnotator extends Annotator {
                constructor(options?: any);
            }
            /**
             * @class
             * @classdesc Class representing an POSTaggerAnnotator. Hydrates {@link Token.pos()}
             * @extends Annotator
             * @memberof CoreNLP/simple/annotator
             * @requires tokenize, ssplit, pos
             * @see {@link https://stanfordnlp.github.io/CoreNLP/pos.html|POSTaggerAnnotator}
             */
            class POSTaggerAnnotator extends Annotator {
                constructor(options?: any);
            }
            /**
             * @class
             * @classdesc Class representing an RegexNERAnnotator.
             * @extends Annotator
             * @memberof CoreNLP/simple/annotator
             * @requires tokenize, ssplit, pos, regexner
             * @see {@link https://stanfordnlp.github.io/CoreNLP/regexner.html|RegexNERAnnotator}
             */
            class RegexNERAnnotator extends Annotator {
                constructor(options?: any);
            }
            /**
             * @class
             * @classdesc Class representing an RelationExtractorAnnotator.
             * @extends Annotator
             * @memberof CoreNLP/simple/annotator
             * @requires tokenize, ssplit, pos, lemma, ner, depparse, relation
             * @see {@link https://stanfordnlp.github.io/CoreNLP/relation.html|RelationExtractorAnnotator}
             */
            class RelationExtractorAnnotator extends Annotator {
                constructor(options?: any);
            }
            /**
             * @class
             * @classdesc Class representing an WordsToSentenceAnnotator.
             *            Combines multiple {@link Token}s into sentences
             * @extends Annotator
             * @memberof CoreNLP/simple/annotator
             * @requires tokenize, ssplit
             * @see {@link https://stanfordnlp.github.io/CoreNLP/ssplit.html|WordsToSentenceAnnotator}
             */
            class WordsToSentenceAnnotator extends Annotator {
                constructor(options?: any);
            }
            /**
             * @class
             * @classdesc Class representing an TokenizerAnnotator. Identifies {@link Token}s
             * @extends Annotator
             * @memberof CoreNLP/simple/annotator
             * @requires tokenize
             * @see {@link https://stanfordnlp.github.io/CoreNLP/tokenize.html|TokenizerAnnotator}
             */
            class TokenizerAnnotator extends Annotator {
                constructor(options?: any);
            }
        }
    }

    /**
     * @namespace CoreNLP/util
     * @description Utilities
     */
    namespace util {
        /**
         * @class
         * @classdesc Class representing a Parse tree structure
         * @memberof CoreNLP/util
         * @description
         * The nodes are given in order left to right as the words in a sentence appears
         * The leaves are grouped into semantic representations provided by the Annotator
         * This class is pretty useful to use along with the ParserAnnotator
         * @see inspired on {@link http://www.nltk.org/howto/tree.html|Tree}
         * @see the lecture {@link http://www.cs.cornell.edu/courses/cs474/2004fa/lec1.pdf|Tree Syntax of Natural Language}
         */
        class Tree {
            constructor(node: Node);
            /**
             * Get a Tree string representation for debugging purposes
             * @returns {string} tree
             */
            dump(): string;
            /**
             * Performs Deep-first Search calling a visitor for each node
             * @see {@link https://en.wikipedia.org/wiki/Depth-first_search|DFS}
             */
            visitDeepFirst(): void;
            /**
             * Performs Deep-first Search calling a visitor for each node, from right to left
             * @see {@link https://en.wikipedia.org/wiki/Depth-first_search|DFS}
             */
            visitDeepFirstRight(): void;
            /**
             * Performs Deep-first Search calling a visitor only over leaves
             * @see {@link https://en.wikipedia.org/wiki/Depth-first_search|DFS}
             */
            visitLeaves(): void;
            /**
             * @param {Sentence} sentence
             * @param {boolean} [doubleLink] whether the child nodes should have a reference
             * to their parent or not - this allows the use of {@link Node.parent()}
             * @returns {Tree} tree
             */
            static fromSentence(sentence: CoreNLP.simple.Sentence, doubleLink?: boolean): Tree;
            /**
             * @param {string} str
             * @param {boolean} [doubleLink] whether the child nodes should have a reference
             * to their parent or not - this allows the use of {@link Node.parent()}
             * @returns {Tree} tree
             */
            static fromString(str: string, doubleLink?: boolean): Tree;
            /**
             * Get a Tree string representation for debugging purposes
             * @returns {string} tree
             */
            dump(): string;
            /**
             * Performs Deep-first Search calling a visitor for each node
             * @see {@link https://en.wikipedia.org/wiki/Depth-first_search|DFS}
             */
            visitDeepFirst(): void;
            /**
             * Performs Deep-first Search calling a visitor for each node, from right to left
             * @see {@link https://en.wikipedia.org/wiki/Depth-first_search|DFS}
             */
            visitDeepFirstRight(): void;
            /**
             * Performs Deep-first Search calling a visitor only over leaves
             * @see {@link https://en.wikipedia.org/wiki/Depth-first_search|DFS}
             */
            visitLeaves(): void;
            /**
             * @param {Sentence} sentence
             * @param {boolean} [doubleLink] whether the child nodes should have a reference
             * to their parent or not - this allows the use of {@link Node.parent()}
             * @returns {Tree} tree
             */
            static fromSentence(sentence: CoreNLP.simple.Sentence, doubleLink?: boolean): Tree;
            /**
             * @param {string} str
             * @param {boolean} [doubleLink] whether the child nodes should have a reference
             * to their parent or not - this allows the use of {@link Node.parent()}
             * @returns {Tree} tree
             */
            static fromString(str: string, doubleLink?: boolean): Tree;
        }
    }
}

export default CoreNLP;

/**
 * @class
 * @classdesc Class representing a Pipeline.
 */
export class Pipeline {
    constructor(properties: Properties, language?: string, connector?: ConnectorServer | ConnectorCli);
    /**
     * Retrieves the current Service used by the pipeline
     * @param {Service} service
     */
    getService(service: Service): void;
    /**
     * Execute the pipeline against the annotable object, adding annotations to it.
     * Calls the service and loads the associated response metadata into the Annotable model
     * @async
     * @param {Annotable} annotable - the document or sentence to be annotated
     * @returns {Promise<Annotable>} annotated document / sentence
     */
    annotate<T extends CoreNLP.simple.Annotable>(annotable: T): Promise<T>;
    /**
     * @param {Array.<Annotator>} requiredAnnotators
     */
    assert(requiredAnnotators: CoreNLP.simple.Annotator[]): void;
    /**
     * Annotates the given Expression instance with matching groups and/or Tokens
     * @param {Expression} expression - An annotable expression containing a TokensRegex pattern
     * @param {boolean} [annotateExpression] - Whether to hydrate the annotations with tokens or not.
     * IMPORTANT: The optional parameter 'annotateExpression' if true, will run the CoreNLP pipeline
     *            twice.  First for the TokensRegex annotation, and one more for the standard pipeline
     *            Token annotations (pos, ner, lemma, etc).
     * @returns {Expression} expression - The current expression instance
     */
    annotateTokensRegex(expression: CoreNLP.simple.Expression, annotateExpression?: boolean): CoreNLP.simple.Expression;
    /**
     * Annotates the given Expression instance with matching groups and/or Tokens
     * @param {Expression} expression - An annotable expression containing a Semgrex pattern
     * @param {boolean} [annotateExpression] - Whether to hydrate the annotations with tokens or not.
     * IMPORTANT: The optional parameter 'annotateExpression' if true, will run the CoreNLP pipeline
     *            twice.  First for the Semgrex annotation, and one more for the standard pipeline
     *            Token annotations (pos, ner, lemma, etc).
     * @returns {Expression} expression - The current expression instance
     */
    annotateSemgrex(expression: CoreNLP.simple.Expression, annotateExpression?: boolean): CoreNLP.simple.Expression;
    /**
     * Annotates the given Expression instance with matching groups and/or Tokens
     * @param {Expression} expression - An annotable expression containing a Tregex pattern
     * @param {boolean} [annotateExpression] - Whether to hydrate the annotations with tokens or not.
     * IMPORTANT: The optional parameter 'annotateExpression' if true, will run the CoreNLP pipeline
     *            twice.  First for the Tregex annotation, and one more for the standard pipeline
     *            Token annotations (pos, ner, lemma, etc).
     * @returns {Expression} expression - The current expression instance
     */
    annotateTregex(expression: CoreNLP.simple.Expression, annotateExpression?: boolean): CoreNLP.simple.Expression;
    /**
     * Retrieves the current Service used by the pipeline
     * @param {Service} service
     */
    getService(service: Service): void;
    /**
     * Execute the pipeline against the annotable object, adding annotations to it.
     * Calls the service and loads the associated response metadata into the Annotable model
     * @async
     * @param {Annotable} annotable - the document or sentence to be annotated
     * @returns {Promise<Annotable>} annotated document / sentence
     */
    annotate(annotable: CoreNLP.simple.Annotable): Promise<CoreNLP.simple.Annotable>;
    /**
     * @param {Array.<Annotator>} requiredAnnotators
     */
    assert(requiredAnnotators: CoreNLP.simple.Annotator[]): void;
    /**
     * Annotates the given Expression instance with matching groups and/or Tokens
     * @param {Expression} expression - An annotable expression containing a TokensRegex pattern
     * @param {boolean} [annotateExpression] - Whether to hydrate the annotations with tokens or not.
     * IMPORTANT: The optional parameter 'annotateExpression' if true, will run the CoreNLP pipeline
     *            twice.  First for the TokensRegex annotation, and one more for the standard pipeline
     *            Token annotations (pos, ner, lemma, etc).
     * @returns {Expression} expression - The current expression instance
     */
    annotateTokensRegex(expression: CoreNLP.simple.Expression, annotateExpression?: boolean): CoreNLP.simple.Expression;
    /**
     * Annotates the given Expression instance with matching groups and/or Tokens
     * @param {Expression} expression - An annotable expression containing a Semgrex pattern
     * @param {boolean} [annotateExpression] - Whether to hydrate the annotations with tokens or not.
     * IMPORTANT: The optional parameter 'annotateExpression' if true, will run the CoreNLP pipeline
     *            twice.  First for the Semgrex annotation, and one more for the standard pipeline
     *            Token annotations (pos, ner, lemma, etc).
     * @returns {Expression} expression - The current expression instance
     */
    annotateSemgrex(expression: CoreNLP.simple.Expression, annotateExpression?: boolean): CoreNLP.simple.Expression;
    /**
     * Annotates the given Expression instance with matching groups and/or Tokens
     * @param {Expression} expression - An annotable expression containing a Tregex pattern
     * @param {boolean} [annotateExpression] - Whether to hydrate the annotations with tokens or not.
     * IMPORTANT: The optional parameter 'annotateExpression' if true, will run the CoreNLP pipeline
     *            twice.  First for the Tregex annotation, and one more for the standard pipeline
     *            Token annotations (pos, ner, lemma, etc).
     * @returns {Expression} expression - The current expression instance
     */
    annotateTregex(expression: CoreNLP.simple.Expression, annotateExpression?: boolean): CoreNLP.simple.Expression;
}

/**
 * @class
 * @classdesc Class representing a Properties set.
 */
export class Properties {
    constructor(props: any);
    /**
     * Property setter
     * @param {string} name - the property name
     * @param {*} value - the property value
     */
    setProperty(name: string, value: any): void;
    /**
     * Property getter
     * @param {string} name - the property name
     * @param {*} default - the defaut value to return if not set
     * @returns {*} value - the property value
     */
    getProperty(name: string, defaultValue: any): any;
    /**
     * Returns an Object map of the given properties
     * @returns {Object} properties - the properties object
     */
    getProperties(): any;
    /**
     * Returns a JSON object of the given properties
     * @returns {Object} json - the properties object
     */
    toJSON(): any;
    /**
     * Returns a properties file-like string of the given properties
     * @returns {string} properties - the properties content
     */
    toPropertiessFileContent(): string;
    /**
     * Property setter
     * @param {string} name - the property name
     * @param {*} value - the property value
     */
    setProperty(name: string, value: any): void;
    /**
     * Property getter
     * @param {string} name - the property name
     * @param {*} default - the defaut value to return if not set
     * @returns {*} value - the property value
     */
    getProperty(name: string, defaultValue: any): any;
    /**
     * Returns an Object map of the given properties
     * @returns {Object} properties - the properties object
     */
    getProperties(): any;
    /**
     * Returns a JSON object of the given properties
     * @returns {Object} json - the properties object
     */
    toJSON(): any;
    /**
     * Returns a properties file-like string of the given properties
     * @returns {string} properties - the properties content
     */
    toPropertiessFileContent(): string;
}

/**
 * @class
 * @classdesc Middleware that interfaces between the pipeline and the connector strategies
 */
export class Service {
    constructor(connector: ConnectorServer | ConnectorCli, language?: 'English' | 'French' | 'German' | 'Spanish' | 'Unspecified' | 'Whitesapce');
}

/**
 * @class
 * @classdesc Class representing an CorefChain
 */
export class CorefChain {
    constructor(mentions: CorefMention[]);
    /**
     * Retrieves all the contained CorefMention instances
     * @returns {Array.<CorefMention>} mentions
     */
    mentions(): CorefMention[];
    /**
     * Retrieves a CorefMention at the index specified
     * @param {number} index
     * @returns {CorefMention} mention
     */
    mention(index: number): CorefMention;
    /**
     * Retrieves the first representative mention
     * @returns {CorefMention} mention
     */
    representative(): CorefMention;
    /**
     * Retrieves all the non-representative mentions
     * @returns {Array.<CorefMention>} mentions
     */
    nonRepresentatives(): CorefMention[];
    /**
     * Gets or sets a Document reference for the current coref-chain
     * @param {Document} doc
     * @returns {Document} doc
     */
    document(doc: CoreNLP.simple.Document): CoreNLP.simple.Document;
    /**
     * Update an instance of CorefChain with Document references to Sentence(s) and their Token(s)
     * @param {Document} doc - a Document object, the same one used to generate corefs annotations
     * @returns {CorefChain} chain - The current chain instance
     */
    fromDocument(doc: CoreNLP.simple.Document): CorefChain;
    /**
     * Update an instance of CorefChain with data provided by a JSON
     * @param {Array.<CorefMentionJSON>} data - A sentence corefs mentions chain, as
     *  returned by CoreNLP API service
     * @returns {CorefChain} chain - The current chain instance
     */
    fromJSON(data: CorefMentionJSON[]): CorefChain;
    /**
     * Get an instance of CorefChain from a given JSON of sentence corefs
     * @param {Array.<CorefMentionJSON>} data - The sentence corefs data, as
     *  returned by CoreNLP API service
     * @returns {CorefChain} sentenchain - A new CorefChain instance
     */
    static fromJSON(data: CorefMentionJSON[]): CorefChain;
    /**
     * Retrieves all the contained CorefMention instances
     * @returns {Array.<CorefMention>} mentions
     */
    mentions(): CorefMention[];
    /**
     * Retrieves a CorefMention at the index specified
     * @param {number} index
     * @returns {CorefMention} mention
     */
    mention(index: number): CorefMention;
    /**
     * Retrieves the first representative mention
     * @returns {CorefMention} mention
     */
    representative(): CorefMention;
    /**
     * Retrieves all the non-representative mentions
     * @returns {Array.<CorefMention>} mentions
     */
    nonRepresentatives(): CorefMention[];
    /**
     * Gets or sets a Document reference for the current coref-chain
     * @param {Document} doc
     * @returns {Document} doc
     */
    document(doc: CoreNLP.simple.Document): CoreNLP.simple.Document;
    /**
     * Update an instance of CorefChain with Document references to Sentence(s) and their Token(s)
     * @param {Document} doc - a Document object, the same one used to generate corefs annotations
     * @returns {CorefChain} chain - The current chain instance
     */
    fromDocument(doc: CoreNLP.simple.Document): CorefChain;
    /**
     * Update an instance of CorefChain with data provided by a JSON
     * @param {Array.<CorefMentionJSON>} data - A sentence corefs mentions chain, as
     *  returned by CoreNLP API service
     * @returns {CorefChain} chain - The current chain instance
     */
    fromJSON(data: CorefMentionJSON[]): CorefChain;
    /**
     * Get an instance of CorefChain from a given JSON of sentence corefs
     * @param {Array.<CorefMentionJSON>} data - The sentence corefs data, as
     *  returned by CoreNLP API service
     * @returns {CorefChain} sentenchain - A new CorefChain instance
     */
    static fromJSON(data: CorefMentionJSON[]): CorefChain;
}

/**
 * A CorefMention.
 * @typedef CorefMentionJSON
 * @property {number} id - Mention ID
 * @property {string} text - The text (literal word) of the mention
 * @property {number} sentNum - 1-based index of the sentence containinng this mention
 * @property {number} headIndex - 1-based index
 * @property {number} startIndex - 1-based index
 * @property {number} endIndex - 1-based index
 * @property {boolean} isRepresentativeMention - Wehther the mention word is representative or not
 * @property {("ANIMATE"|"INANIMATE"|"UNKNOWN")} animacy - Mention's animacy
 * @property {("FEMALE"|"MALE"|"NEUTRAL"|"UNKNOWN")} gender - Gender of the mention
 * @property {("SINGULAR"|"PLURAL"|"UNKNOWN")} number - Cardinality of the mention
 * @property {("PRONOMINAL"|"NOMINAL"|"PROPER"|"LIST")} type - Mention type
 * @property {Array} position - Position is a binary tuple of
 *    (sentence number, mention number in that sentence). This is used for indexing by mention.
 *
 * @see {@link https://github.com/stanfordnlp/CoreNLP/blob/7cfaf869f9500da16b858ab1a2835234ae46f96e/src/edu/stanford/nlp/dcoref/CorefChain.java#L148}
 * @see {@link https://github.com/stanfordnlp/CoreNLP/blob/master/src/edu/stanford/nlp/dcoref/Dictionaries.java} for enum definitions
 */
export type CorefMentionJSON = {
    id: number;
    text: string;
    sentNum: number;
    headIndex: number;
    startIndex: number;
    endIndex: number;
    isRepresentativeMention: boolean;
    animacy: "ANIMATE" | "INANIMATE" | "UNKNOWN";
    gender: "FEMALE" | "MALE" | "NEUTRAL" | "UNKNOWN";
    number: "SINGULAR" | "PLURAL" | "UNKNOWN";
    type: "PRONOMINAL" | "NOMINAL" | "PROPER" | "LIST";
    position: number[];
};

/**
 * @class
 * @classdesc Class representing an CorefMention
 */
export class CorefMention {
    /**
     * Retrieves the mention ID
     * @returns {string} id
     */
    id(): string;
    /**
     * Retrieves the mention text
     * @returns {string} text
     */
    text(): string;
    /**
     * Retrieves the mention sentence number
     * @see {@link CorefMention.sentence()} for simplicity
     * @returns {number} sentNum
     */
    sentNum(): number;
    /**
     * Retrieves the mention headIndex
     * @returns {number} headIndex
     */
    headIndex(): number;
    /**
     * Retrieves the mention startIndex
     * @returns {number} startIndex
     */
    startIndex(): number;
    /**
     * Retrieves the mention endIndex
     * @returns {number} endIndex
     */
    endIndex(): number;
    /**
     * Tells you if the mentions is representative or not
     * @returns {boolean} isRepresentativeMention
     */
    isRepresentativeMention(): boolean;
    /**
     * Retrieves the mention animacy
     * @returns {("ANIMATE"|"INANIMATE"|"UNKNOWN")} animacy
     */
    animacy(): "ANIMATE" | "INANIMATE" | "UNKNOWN";
    /**
     * Retrieves the mention gender
     * @returns {("FEMALE"|"MALE"|"NEUTRAL"|"UNKNOWN")} gender
     */
    gender(): "FEMALE" | "MALE" | "NEUTRAL" | "UNKNOWN";
    /**
     * Retrieves the mention number
     * @returns {("SINGULAR"|"PLURAL"|"UNKNOWN")} number
     */
    number(): "SINGULAR" | "PLURAL" | "UNKNOWN";
    /**
     * Retrieves the mention type
     * @returns {("PRONOMINAL"|"NOMINAL"|"PROPER"|"LIST")} type
     */
    type(): "PRONOMINAL" | "NOMINAL" | "PROPER" | "LIST";
    /**
     * Retrieves the mention's sentence container
     * @returns {Sentence} sentence
     */
    sentence(): CoreNLP.simple.Sentence;
    /**
     * Retrieves the mention's associated token
     * @returns {Token} token
     */
    token(): CoreNLP.simple.Token;
    /**
     * Update an instance of CorefMention with data provided by a JSON
     * @param {CorefMentionJSON} data - The mention data, as returned by CoreNLP API service
     * @returns {CorefMention} mention - The current mention instance
     */
    fromJSON(data: CorefMentionJSON): CorefMention;
    /**
     * Get an instance of CorefMention from a given JSON
     * @param {CorefMentionJSON} data - The match data, as returned by CoreNLP API service
     * @returns {CorefMention} mention - A new CorefMention instance
     */
    static fromJSON(data: CorefMentionJSON): CorefMention;
    /**
     * Retrieves the mention ID
     * @returns {string} id
     */
    id(): string;
    /**
     * Retrieves the mention text
     * @returns {string} text
     */
    text(): string;
    /**
     * Retrieves the mention sentence number
     * @see {@link CorefMention.sentence()} for simplicity
     * @returns {number} sentNum
     */
    sentNum(): number;
    /**
     * Retrieves the mention headIndex
     * @returns {number} headIndex
     */
    headIndex(): number;
    /**
     * Retrieves the mention startIndex
     * @returns {number} startIndex
     */
    startIndex(): number;
    /**
     * Retrieves the mention endIndex
     * @returns {number} endIndex
     */
    endIndex(): number;
    /**
     * Tells you if the mentions is representative or not
     * @returns {boolean} isRepresentativeMention
     */
    isRepresentativeMention(): boolean;
    /**
     * Retrieves the mention animacy
     * @returns {("ANIMATE"|"INANIMATE"|"UNKNOWN")} animacy
     */
    animacy(): "ANIMATE" | "INANIMATE" | "UNKNOWN";
    /**
     * Retrieves the mention gender
     * @returns {("FEMALE"|"MALE"|"NEUTRAL"|"UNKNOWN")} gender
     */
    gender(): "FEMALE" | "MALE" | "NEUTRAL" | "UNKNOWN";
    /**
     * Retrieves the mention number
     * @returns {("SINGULAR"|"PLURAL"|"UNKNOWN")} number
     */
    number(): "SINGULAR" | "PLURAL" | "UNKNOWN";
    /**
     * Retrieves the mention type
     * @returns {("PRONOMINAL"|"NOMINAL"|"PROPER"|"LIST")} type
     */
    type(): "PRONOMINAL" | "NOMINAL" | "PROPER" | "LIST";
    /**
     * Retrieves the mention's sentence container
     * @returns {Sentence} sentence
     */
    sentence(): CoreNLP.simple.Sentence;
    /**
     * Retrieves the mention's associated token
     * @returns {Token} token
     */
    token(): CoreNLP.simple.Token;
    /**
     * Update an instance of CorefMention with data provided by a JSON
     * @param {CorefMentionJSON} data - The mention data, as returned by CoreNLP API service
     * @returns {CorefMention} mention - The current mention instance
     */
    fromJSON(data: CorefMentionJSON): CorefMention;
    /**
     * Get an instance of CorefMention from a given JSON
     * @param {CorefMentionJSON} data - The match data, as returned by CoreNLP API service
     * @returns {CorefMention} mention - A new CorefMention instance
     */
    static fromJSON(data: CorefMentionJSON): CorefMention;
}

/**
 * The CoreNLP API JSON structure representing a document
 * @typedef DocumentJSON
 * @property {number} index
 * @property {Array.<Sentence>} sentences
 */
declare type DocumentJSON = {
    index: number;
    sentences: CoreNLP.simple.Sentence[];
};

/**
 * @typedef ExpressionSentenceMatchGroup
 * @property {string} label - group label
 * @property {number} begin - 0-based index of the matched group, relative to the given text
 * @property {number} end - 0-based index of the matched group, relative to the given text
 * @property {Token} [token] - onluy given if aggregated with an annotated Sentence or Document
 * @property {ExpressionSentenceMatchGroup} [$label] - other groups inside
 */
declare type ExpressionSentenceMatchGroup = {
    label: string;
    begin: number;
    end: number;
    token?: CoreNLP.simple.Token;
    $label?: ExpressionSentenceMatchGroup;
};

/**
 * A ExpressionSentenceMatch of either 'TokensRegex', 'Semgrex' or 'Tregex'.
 * @typedef ExpressionSentenceMatchJSON
 * @property {number} begin - word begin position, starting from zero
 * @property {number} end - word end position, starting from zero (no match ends at 0)
 * @property {string} text - matched text
 * @property {string} [$label] - any label, as defined in the expression pattern
 */
declare type ExpressionSentenceMatchJSON = {
    begin: number;
    end: number;
    text: string;
    $label?: string;
};

/**
 * @class
 * @classdesc Class representing an ExpressionSentenceMatch
 */
declare class ExpressionSentenceMatch {
    /**
     * Returns the main and labeled groups as a list of ExpressionSentenceMatchGroup
     * @returns {Array.<ExpressionSentenceMatchGroup>} groups
     */
    groups(): ExpressionSentenceMatchGroup[];
    /**
     * Returns the labeled group as ExpressionSentenceMatchGroup from a given label
     * @description
     * Nodes in a Macthed expression can be named, we call them groups here, and
     * the labels are the name of the nodes.
     * @see {@link https://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/semgraph/semgrex/SemgrexPattern.html#Naming_nodes}
     * @param {string} label - The label name, not prefixed wih $
     * @returns {ExpressionSentenceMatchGroup} group
     */
    group(label: string): ExpressionSentenceMatchGroup;
    /**
     * Retrieves the list of labels (aliases) available for the current sentence match.
     * @description
     * Labels are those aliases you can add to a group match expression, for example,
     * in Semgrex, you can do {ner:/PERSON/=good_guy}, from where "good_guy" would be the label
     * and internally it will come as $good_guy as a member of {@link ExpressionSentenceMatchGroup}.
     * @returns {Array.<string>} labels
     */
    labels(): string[];
    /**
     * Update an instance of ExpressionSentenceMatch with data provided by a JSON
     * @param {ExpressionSentenceMatchJSON} data - The match data, as returned by CoreNLP API service
     * @returns {ExpressionSentenceMatch} expression - The current match instance
     */
    fromJSON(data: ExpressionSentenceMatchJSON): ExpressionSentenceMatch;
    /**
     * Get an instance of ExpressionSentenceMatch from a given JSON
     * @param {ExpressionSentenceMatchJSON} data - The match data, as returned by CoreNLP API service
     * @returns {ExpressionSentenceMatch} match - A new ExpressionSentenceMatch instance
     */
    static fromJSON(data: ExpressionSentenceMatchJSON): ExpressionSentenceMatch;
    /**
     * Returns the main and labeled groups as a list of ExpressionSentenceMatchGroup
     * @returns {Array.<ExpressionSentenceMatchGroup>} groups
     */
    groups(): ExpressionSentenceMatchGroup[];
    /**
     * Returns the labeled group as ExpressionSentenceMatchGroup from a given label
     * @description
     * Nodes in a Macthed expression can be named, we call them groups here, and
     * the labels are the name of the nodes.
     * @see {@link https://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/semgraph/semgrex/SemgrexPattern.html#Naming_nodes}
     * @param {string} label - The label name, not prefixed wih $
     * @returns {ExpressionSentenceMatchGroup} group
     */
    group(label: string): ExpressionSentenceMatchGroup;
    /**
     * Retrieves the list of labels (aliases) available for the current sentence match.
     * @description
     * Labels are those aliases you can add to a group match expression, for example,
     * in Semgrex, you can do {ner:/PERSON/=good_guy}, from where "good_guy" would be the label
     * and internally it will come as $good_guy as a member of {@link ExpressionSentenceMatchGroup}.
     * @returns {Array.<string>} labels
     */
    labels(): string[];
    /**
     * Update an instance of ExpressionSentenceMatch with data provided by a JSON
     * @param {ExpressionSentenceMatchJSON} data - The match data, as returned by CoreNLP API service
     * @returns {ExpressionSentenceMatch} expression - The current match instance
     */
    fromJSON(data: ExpressionSentenceMatchJSON): ExpressionSentenceMatch;
    /**
     * Get an instance of ExpressionSentenceMatch from a given JSON
     * @param {ExpressionSentenceMatchJSON} data - The match data, as returned by CoreNLP API service
     * @returns {ExpressionSentenceMatch} match - A new ExpressionSentenceMatch instance
     */
    static fromJSON(data: ExpressionSentenceMatchJSON): ExpressionSentenceMatch;
}

declare type ExpressionSentenceJSON = { }

/**
 * @class
 * @classdesc Class representing an ExpressionSentence
 */
declare class ExpressionSentence {
    constructor(matches: ExpressionSentenceMatch[]);
    /**
     * Retrieves all the contained ExpressionSentenceMatch instances
     * @returns {Array.<ExpressionSentenceMatch>} matches
     */
    matches(): ExpressionSentenceMatch[];
    /**
     * Retrieves a ExpressionSentenceMatch at the index specified
     * @param {number} index
     * @returns {ExpressionSentenceMatch} match
     */
    match(index: number): ExpressionSentenceMatch;
    /**
     * Hydrates the current ExpressionSentence match groups with Token objects.
     * @description
     * The Expression / ExpressionSentence objects comes from outside the standard CoreNLP pipelines.
     * This mean that neither 'TokensRegex', 'Semgrex' nor 'Tregex' will tag the nodes with POS,
     * lemma, NER or any otehr annotation data.  This is sometimes a usful resource to count with, if
     * you can apart of getting the matching groups, get the annotated tokens for each word in the
     * match group.
     * @returns {ExpressionSentence} instance = The current instance
     */
    mergeTokensFromSentence(): ExpressionSentence;
    /**
     * Update an instance of ExpressionSentence with data provided by a JSON
     * @param {ExpressionSentenceJSON} data - The expression data, as returned by CoreNLP API service
     * @returns {ExpressionSentenceJSON} sentence - The current sentence instance
     */
    fromJSON(data: ExpressionSentenceJSON): ExpressionSentenceJSON;
    /**
     * Get an instance of ExpressionSentence from a given JSON of sentence matches
     * @param {ExpressionSentenceJSON} data - The sentence data, as returned by CoreNLP API service
     * @returns {ExpressionSentence} sentence - A new ExpressionSentence instance
     */
    static fromJSON(data: ExpressionSentenceJSON): ExpressionSentence;
    /**
     * Retrieves all the contained ExpressionSentenceMatch instances
     * @returns {Array.<ExpressionSentenceMatch>} matches
     */
    matches(): ExpressionSentenceMatch[];
    /**
     * Retrieves a ExpressionSentenceMatch at the index specified
     * @param {number} index
     * @returns {ExpressionSentenceMatch} match
     */
    match(index: number): ExpressionSentenceMatch;
    /**
     * Hydrates the current ExpressionSentence match groups with Token objects.
     * @description
     * The Expression / ExpressionSentence objects comes from outside the standard CoreNLP pipelines.
     * This mean that neither 'TokensRegex', 'Semgrex' nor 'Tregex' will tag the nodes with POS,
     * lemma, NER or any otehr annotation data.  This is sometimes a usful resource to count with, if
     * you can apart of getting the matching groups, get the annotated tokens for each word in the
     * match group.
     * @returns {ExpressionSentence} instance = The current instance
     */
    mergeTokensFromSentence(): ExpressionSentence;
    /**
     * Update an instance of ExpressionSentence with data provided by a JSON
     * @param {ExpressionSentenceJSON} data - The expression data, as returned by CoreNLP API service
     * @returns {ExpressionSentenceJSON} sentence - The current sentence instance
     */
    fromJSON(data: ExpressionSentenceJSON): ExpressionSentenceJSON;
    /**
     * Get an instance of ExpressionSentence from a given JSON of sentence matches
     * @param {ExpressionSentenceJSON} data - The sentence data, as returned by CoreNLP API service
     * @returns {ExpressionSentence} sentence - A new ExpressionSentence instance
     */
    static fromJSON(data: ExpressionSentenceJSON): ExpressionSentence;
}

/**
 * The CoreNLP API JSON structure representing an expression
 * This expression structure can be found as the output of 'TokensRegex',
 * 'Semgrex' and 'Tregex'.
 * @typedef ExpressionJSON
 * @property {number} index
 * @property {Array.<Array.<ExpressionSentenceMatch>>} sentences
 */
declare type ExpressionJSON = {
    index: number;
    sentences: ExpressionSentenceMatch[][];
};

/**
 * The CoreNLP API JSON structure representing a governor
 * @typedef GovernorJSON
 * @property {string} dep
 * @property {number} governor
 * @property {string} governorGloss
 * @property {number} dependent
 * @property {string} dependentGloss
 */
declare type GovernorJSON = {
    dep: string;
    governor: number;
    governorGloss: string;
    dependent: number;
    dependentGloss: string;
};

/**
 * The CoreNLP API JSON structure representing a sentence
 * @typedef SentenceJSON
 * @property {number} index - 1-based index, as they come indexed by StanfordCoreNLP
 * @property {Array.<Token>} tokens
 */
declare type SentenceJSON = {
    index: number;
    tokens: CoreNLP.simple.Token[];
};

/**
 * The CoreNLP API JSON structure representing a token
 * @typedef TokenJSON
 * @property {number} index
 * @property {string} word
 * @property {string} originalText
 * @property {number} characterOffsetBegin
 * @property {number} characterOffsetEnd
 * @property {string} before
 * @property {string} after
 */
declare type TokenJSON = {
    index: number;
    word: string;
    originalText: string;
    characterOffsetBegin: number;
    characterOffsetEnd: number;
    before: string;
    after: string;
};

/**
 * @typedef PosInfo
 * @description
 * PosInfo does not come as part of the CoreNLP.  It is an indexed reference of POS tags
 * by language provided by this library.  It's only helpful for analysis and study.  The
 * data was collected from different documentation resources on the Web.
 * The PosInfo may vary depending on the POS annotation types used, for example, CoreNLP
 * for Spanish uses custom POS tags developed by Stanford, but this can also be changed
 * to Universal Dependencies, which uses different tags.
 * @property {string} group
 * @property {string} tag
 * @property {Array.<string>} examples
 */
declare type PosInfo = {
    group: string;
    tag: string;
    examples: string[];
};

/**
 * @class
 * @classdesc Class representing a Sentence Tree Node
 */
declare class Node {
    constructor();
    /**
     * Sets the language ISO (given by the pipeline during the annotation process)
     * This is solely to keep track of the language chosen for further analysis
     * @return {string} text
     */
    setLanguageISO(): string;
    /**
     * Retrieves the language ISO
     * @return {string} text
     */
    getLanguageISO(): string;
    /**
     * Sets the language ISO (given by the pipeline during the annotation process)
     * This is solely to keep track of the language chosen for further analysis
     * @return {string} text
     */
    setLanguageISO(): string;
    /**
     * Retrieves the language ISO
     * @return {string} text
     */
    getLanguageISO(): string;
}

Question about usage

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);
  });

browserify does not work until package.json modified for request-promise-native.js

Tried to browserify my js file requiring corenlp, and only succeeded after I manually modified the line:
"request-promise-native": "./src/polyfills/request-promise-native.js",
to
"request-promise-native": "./dist/polyfills/request-promise-native.js",
I am new to node.js, and not sure if this is an issue. Just reporting the situation.

Trees don't double link properly

Trees only add a parent to direct children of the root. Looks like the recursive call in tree.js _transformTree doesn't pass the doubleLink bool, so all children below root's immediate children don't get a parent.

Line 259:
const childNode = this._transformTree(n);
Should be:
const childNode = this._transformTree(n, doubleLink);

Update README.md

Add:

  • instructions to quickly start
  • description
  • project structure
  • add examples

<h1>404 Not Found</h1>No context found for request

I'm trying to connect to this endpoint: https://corenlp.run/ instead of my localhost (for computer speed reasons).

I got the above response when I tried creating a custom connector. Not sure what it means, but the endpoint seems correct.

// Setting the connector up
const connector = new CoreNLP.ConnectorServer({ dsn: "https://corenlp.run/" })

// passing it into the pipeline
const pipeline = new CoreNLP.Pipeline(props, lang, connector);

These are the two most relevant lines of code. Not sure if more is needed.

Thanks for all the help.

Implementing coref (for english)

Hi guys. I wanted to inquire about the status and plan on the implementation of coref. Apparently it is not implemented yet if looked up in the API Documentation. Since I'm building a tool where this would be a nice feature I would like to know if this will be implemented any time soon.

If this isnt the case: Can you sketch a way to implement it? I realized that the pipeline would even throw an error if I set "dcoref" in the corenlp.Properties:
(node:3320) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'toString' of undefined
Code:
`
nlpStatus.connector = new corenlp.ConnectorServer({dsn: nlpStatus.host});
nlpStatus.props = new corenlp.Properties({
annotators: 'tokenize,ssplit,pos,lemma,ner,parse, dcoref'});

nlpStatus.pipeline = new corenlp.Pipeline(nlpStatus.props, language , nlpStatus.connector);`

So my request is that the pipeline just generally can use this annotator so I can extract the coreference information out of it. Thank you for your time and replys.

English example, Spanish setup ?

This note may be obvious to more experienced users, but I had a small difficulty because of what may be an inconsistency between the docs and the shipped example configuration.

The first example in the github README.MD shows how to specify "English" for the parser language. But in the following setup instructions, the scripts actually download the spanish version of the parser, and the English models don't seem to be present. Because of this, I got an error about missing English files.

In the super-simple installation instructions in the README, it says to run "npm explore corenlp -- npm run corenlp:download" and "npm explore corenlp -- npm run corenlp:server". As of the time of writing, the bash scripts referenced by those commands seem to install and start the Spanish version of the Stanford parser.

The upshot, I think, is one of two corrections is needed; either (1) change "English" in the example to "Spanish" and also change the English example sentence to a Spanish one, or instead (2) modify the download bash script and the server-starting bash script to fetch and run the English instead of the Spanish parser models.

I tried a version of (2) and seem to have gotten it working. In the corenlp:download script, you would change the downloaded filenames to have "-english-" where they now have "-spanish-". In the corenlp:server script, I simply remarked-out the "-serverProperties ..." line, where Spanish is specified. (I realize that now I am not specifying any serverProperties, but I will look further into that and include some as I work more with my project.)

Thanks, gerardobort, for the parser. It is a real godsend. Others may see right through this; it may be a challenge for me just because I am not yet very familiar with the software. It's up to you.

ReferenceError: regeneratorRuntime is not defined

I just installed corenlp from npm and copied the extracted .zip file downloaded from "https://stanfordnlp.github.io/CoreNLP/download.html" in the corenlp folder in my project root.

When first running my code (that I pasted below), executing the first line, the following error occurs:

`ReferenceError: regeneratorRuntime is not defined 
at [MY-MODULE-ROOT]\node_modules\corenlp\dist\simple\annotable.js:112:36
at [MY-MODULE-ROOT]\node_modules\corenlp\dist\simple\annotable.js:142:6
at Object.<anonymous> ([MY-MODULE-ROOT]\node_modules\corenlp\dist\simple\annotable.js:146:2)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> ([MY-MODULE-ROOT]\node_modules\corenlp\dist\simple\document.js:9:18)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> ([MY-MODULE-ROOT]\node_modules\corenlp\dist\index.js:7:17` 

This is my code (the same of the README example):

`var CoreNLP = require('corenlp').default;

CoreNLP.setup('English');
const sent = new CoreNLP.simple.Sentence("I eat an apple.");
sent.applyAnnotator(CoreNLP.simple.annotator.ParserAnnotator)
.then(() => {
    console.log("This is sent.words(): ", JSON.stringify(sent.words()));
})
.catch((reason) => console.error(reason) );`

How can I fix it? Should I modify the corenlp module?

Assert: Semgrex requires class TokenizerAnnotator extends _annotator2.default

Not entirely sure what this means. Here is a code snippet:
`// get the properties and pipeline
const props = new CoreNLP.Properties({
annotators: 'tokenize,ssplit,pos,lemma,ner,parse',
});

// create a new pipline, should only be created once per request
const pipeline = new CoreNLP.Pipeline(props, 'English');

// must use the default
const expr = new CoreNLP.default.simple.Expression(
'Jon Snow eats snow.',
'{ner:PERSON}=who <nsubj ({pos:VBZ}=action >dobj {}=what)');

pipeline.annotateSemgrex(expr, true)
.then(expr => expr.sentence(0).matches().map(match => {
console.log('match', match.group('who'), match.group('action'), match.group('what'));
})).catch(err => {
console.log('err', err)
})`

Support for node engines > 9?

Thanks so much for building this library. I was just wondering what might be in the way of supporting node environments > v9?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.