Sentence

CoreNLP/simple. Sentence

Class representing a Sentence

Constructor

new Sentence(text)

Source:
See:

Create a Sentence

Parameters:
Name Type Description
text string

Extends

  • Annotable

Methods

(static) fromJSON(data, isSentenceopt) → {Sentence}

Source:

Get an instance of Sentence from a given JSON

Parameters:
Name Type Attributes Default Description
data SentenceJSON

The document data, as returned by CoreNLP API service

isSentence boolean <optional>
false

Indicate if the given data represents just the sentence of a full document

Returns:

document - A new Sentence instance

Type
Sentence

fromJSON(data, isSentenceopt) → {Sentence}

Source:

Update an instance of Sentence with data provided by a JSON

Parameters:
Name Type Attributes Default Description
data SentenceJSON

The document data, as returned by CoreNLP API service

isSentence boolean <optional>
false

Indicate if the given data represents just the sentence or a full document with just a sentence inside

Returns:

sentence - The current sentence instance

Type
Sentence

governor() → {Governor}

Source:

Get the N-th annotated governor by the dependency-parser annotator

Requires:
  • DependencyParseAnnotator
Throws:

in case the require annotator was not applied to the sentence

Type
Error
Returns:

governor

Type
Governor

governors() → {Array.<Governor>}

Source:

Get a list of annotated governors by the dependency-parser

Requires:
  • DependencyParseAnnotator
Throws:

in case the require annotator was not applied to the sentence

Type
Error
Returns:

governors

Type
Array.<Governor>

index() → {number}

Source:

Get the index relative to the parent document

Returns:

index

Type
number

lemma(index) → {string}

Source:

Get a string representations of the Nth token lemma of the sentence

Parameters:
Name Type Description
index number

0-based index as they are arranged naturally

Throws:

in case the token for the given index does not exists

Type
Error
Returns:

lemma

Type
string

lemmas() → {Array.<string>}

Source:

Get a string representations of the tokens lemmas of the sentence

Returns:

lemmas

Type
Array.<string>

nerTag(index) → {string}

Source:

Get a string representations of the Nth token nerTag of the sentence

Parameters:
Name Type Description
index number

0-based index as they are arranged naturally

Throws:

in case the token for the given index does not exists

Type
Error
Returns:

nerTag

Type
string

nerTags() → {Array.<string>}

Source:

Get a string representations of the tokens nerTags of the sentence

Returns:

nerTags

Type
Array.<string>

parse() → {string}

Source:

Get a string representation of the parse tree structure

Returns:

parse

Type
string

posTag(index) → {string}

Source:

Get a string representations of the Nth token part of speech of the sentence

Parameters:
Name Type Description
index number

0-based index as they are arranged naturally

Throws:

in case the token for the given index does not exists

Type
Error
Returns:

posTag

Type
string

posTags() → {Array.<string>}

Source:

Get a string representations of the tokens part of speech of the sentence

Returns:

posTags

Type
Array.<string>

setLanguageISO() → {string}

Source:

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

Returns:

text

Type
string

toJSON() → {SentenceJSON}

Source:

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:

data

Type
SentenceJSON

token() → {Token}

Source:

Get the Nth token of the sentence

Requires:
  • TokenizerAnnotator
Throws:

in case the require annotator was not applied to the sentence

Type
Error
Returns:

token

Type
Token

tokens() → {Array.<Token>}

Source:

Get an array of token representations of the sentence words

Requires:
  • TokenizerAnnotator
Throws:

in case the require annotator was not applied to the sentence

Type
Error
Returns:

tokens

Type
Array.<Token>

toString() → {string}

Source:

Get a string representation

Returns:

sentence

Type
string

word(index) → {string}

Source:

Get a string representations of the Nth word of the sentence

Parameters:
Name Type Description
index number

0-based index as they are arranged naturally

Requires:
  • TokenizerAnnotator
Throws:
  • in case the require annotator was not applied to the sentence

    Type
    Error
  • in case the token for the given index does not exists

    Type
    Error
Returns:

word

Type
string

words() → {Array.<string>}

Source:

Get an array of string representations of the sentence words

Requires:
  • TokenizerAnnotator
Throws:

in case the require annotator was not applied to the sentence

Type
Error
Returns:

words

Type
Array.<string>