Class: Session

$.text.analysis. Session

$.text.analysis.Session represents a Text Analysis session.

Caution
The information in this section applies to a feature that is included in the component SAP HANA Advanced Data Processing. To make use of this feature, you must have purchased a license to use SAP HANA Advanced Data Processing.

new Session(p) → {$.text.analysis.Session}

The Session object represents a Text Analysis session.

This constructor function creates a Text Analysis session object. Text Analysis functions can subsequently be invoked using this object and they will use the configuration it was initialized with.

Parameters:
Name Type Description
p object Encapsulates constructor parameters.
Properties
Name Type Description
configuration string Name of (or, generally, a Repository path to) a Text Analysis configuration object. All subsequent operations on the session will assume this configuration. The default path is sap.hana.ta.config
Returns:
A Text Analysis session object that holds context for the session and is used to call the Text Analysis method functions.
Type
$.text.analysis.Session
Example
var TA = new $.text.analysis.Session({
    configuration: 'sap.hana.ta.config::LINGANALYSIS_FULL.hdbtextconfig'
});

Methods

analyze(p) → {$.text.analysis.Session~AnalyzeResult}

This function performs text analysis of the given input document.
Parameters:
Name Type Description
p object Encapsulates analyze parameters.
Properties
Name Type Argument Description
inputDocumentText|
inputDocumentBinaryContent
string | ArrayBuffer Input document to process. One and only one of the following:
inputDocumentText The literal text of the document (type: string). Supported formats are: plain text, html and xml.
inputDocumentBinaryContent The document to be processed in the original format (type: ArrayBuffer).
language string <optional>
Language code of input text. Available languages are listed in SYS.M_TEXT_ANALYSIS_LANGUAGES view.
mimeType string <optional>
Mime type of input text. Available mime types are listed in SYS.M_TEXT_ANALYSIS_MIME_TYPES view.
includePlainText boolen <optional>
If true, the result will contain the 'plainText' property with the plain text output. By default, false.
tokenSeparators string <optional>
A set of additional characters used for token separation. Only ASCII characters are considered. By default, empty string.
languageDetection Array.<string> <optional>
The set of languages to be used for automatic language detection. Available languages are listed in SYS.M_TEXT_ANALYSIS_LANGUAGES view.
Throws:
Throws an error if the parameters object is not valid or the execution fails.
Returns:
AnalyzeResult object.
Type
$.text.analysis.Session~AnalyzeResult
Example
var taResult = TA.analyze({
    inputDocumentText: 'This is a sample sentence.'
});

Type Definitions

AnalyzeResult

Represents a result from a call to the Text Analysis Session analyze() method
Type:
  • object
Properties:
Name Type Argument Description
language string Language code of the input document.
mimeType string Mime type of the input document.
textSize integer Size of the input document in code units.
plainText string <optional>
Plain text extracted from the document. Present only if includePlainText was specified in a call to analyze.
tokens Array.<$.text.analysis.Session~Token> Tokens from the input document.
entities Array.<$.text.analysis.Session~Entity> Named entities from the input document.
metadata Array.<$.text.analysis.Session~Meta> document metadata from the input document.
grammaticalRoles Array.<$.text.analysis.Session~GrammaticalRoles> grammatical role dependents from the input document.

Entity

Represents a named entity retrieved from a call to the Text Analysis Session analyze() method
Type:
  • object
Properties:
Name Type Argument Description
id integer A unique identification number for the entity within the result set.
text string Text of the entity.
normalizedForm string Normalized text of the entity.
label string Label of the entity.
labelPath string Label path of the entity.
offset integer Offset of the entity.
parent integer <optional>
id of the parent entity, if exists.
paragraph integer Paragraph of the entity.
sentence integer Sentence of the entity.

GrammaticalRoleGovernor

Represents an object containing the dependency information of a component in a grammatical role relationship
Type:
  • object
Properties:
Name Type Description
id integer A unique id number of the governor, if the current component is a dependent. Otherwise, -1.
type string Type of grammatical role relationship, or "MainVerb" + voicing of the verb, if the current component is a governor.

GrammaticalRoles

Represents a component of a grammatical role relationship, retrieved from a call to the Text Analysis Session analyze() method
Type:
  • object
Properties:
Name Type Description
id integer A unique identification number for the component.
paragraph integer Paragraph of the component.
sentence integer Sentence of the component.
offset integer Offset of the component.
text string Text of the component.
governors Array.<$.text.analysis.Session~GrammaticalRoleGovernor> array of objects each containing the id of the governor in the relationship and the dependency type

Meta

Represents a document meta information retrieved from a call to the Text Analysis Session analyze() method
Type:
  • object
Properties:
Name Type Argument Description
id integer A unique identification number for the meta information within the result set.
token string Text of the meta information.
tokenType string Type of the meta information.
offset integer Offset of the entity.
parent integer <optional>
id of the parent entity, if exists.

Token

Represents a token retrieved from a call to the Text Analysis Session analyze() method
Type:
  • object
Properties:
Name Type Description
token string Text of the token.
normalizedToken string Normalized text of the token.
partOfSpeech string Part of speech of the token.
offset integer Offset of the token.
paragraph integer Paragraph of the token.
sentence integer Sentence of the token.
stems Array.<string> Stems for the token.