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
|
Returns:
A Text Analysis session object that holds context for the session
and is used to call the Text Analysis method functions.
Example
var TA = new $.text.analysis.Session({
configuration: 'sap.hana.ta.config::LINGANALYSIS_FULL.hdbtextconfig'
});
Methods
-
async analyze(p) → {$.text.analysis.Session~AnalyzeResult}
-
This function performs text analysis of the given input document.
Parameters:
Name Type Description pobject Encapsulates analyze parameters. Properties
Name Type Argument Description inputDocumentText|
inputDocumentBinaryContentstring | 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). languagestring <optional>
Language code of input text. Available languages are listed in SYS.M_TEXT_ANALYSIS_LANGUAGES view. mimeTypestring <optional>
Mime type of input text. Available mime types are listed in SYS.M_TEXT_ANALYSIS_MIME_TYPES view. includePlainTextboolen <optional>
If true, the result will contain the 'plainText' property with the plain text output. By default, false. tokenSeparatorsstring <optional>
A set of additional characters used for token separation. Only ASCII characters are considered. By default, empty string. languageDetectionArray.<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.Example
var taResult = await 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 languagestring Language code of the input document. mimeTypestring Mime type of the input document. textSizeinteger Size of the input document in code units. plainTextstring <optional>
Plain text extracted from the document. Present only if includePlainText was specified in a call to analyze. tokensArray.<$.text.analysis.Session~Token> Tokens from the input document. entitiesArray.<$.text.analysis.Session~Entity> Named entities from the input document. metadataArray.<$.text.analysis.Session~Meta> document metadata from the input document. grammaticalRolesArray.<$.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 idinteger A unique identification number for the entity within the result set. textstring Text of the entity. normalizedFormstring Normalized text of the entity. labelstring Label of the entity. labelPathstring Label path of the entity. offsetinteger Offset of the entity. parentinteger <optional>
id of the parent entity, if exists. paragraphinteger Paragraph of the entity. sentenceinteger 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 idinteger A unique id number of the governor, if the current component is a dependent. Otherwise, -1. typestring 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 idinteger A unique identification number for the component. paragraphinteger Paragraph of the component. sentenceinteger Sentence of the component. offsetinteger Offset of the component. textstring Text of the component. governorsArray.<$.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 idinteger A unique identification number for the meta information within the result set. tokenstring Text of the meta information. tokenTypestring Type of the meta information. offsetinteger Offset of the entity. parentinteger <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 tokenstring Text of the token. normalizedTokenstring Normalized text of the token. partOfSpeechstring Part of speech of the token. offsetinteger Offset of the token. paragraphinteger Paragraph of the token. sentenceinteger Sentence of the token. stemsArray.<string> Stems for the token.