geneea-nlp-client
Version:
The TypeScript Client for Geneea Interpretor G3 API.
260 lines (259 loc) • 12.7 kB
TypeScript
/**
* Object specifying the [text] and [type] of a single paragraph.
*/
export declare class ParaSpec {
readonly type: string;
readonly text: string;
/**
*
* @param type Type of the paragraphs, typically one of [Paragraph.TYPE_TILE], [Paragraph.TYPE_ABSTRACT],
* [Paragraph.TYPE_BODY]; possibly [Paragraph.TYPE_SECTION_HEADING]
* @param text Text of the paragraph.
*/
constructor(type: string, text: string);
/** Paragraph representing a title of the whole document. It's equivalent to [subject]. */
static title(text?: string): ParaSpec;
/** Paragraph representing a subject of the document or email. It's equivalent to [title]. */
static subject(text?: string): ParaSpec;
/** Paragraph representing an abstract of the document. It's equivalent to [lead] and [perex]. */
static abstract(text?: string): ParaSpec;
/** Paragraph representing a lead of the document. It's equivalent to [abstract] and [perex]. */
static lead(text?: string): ParaSpec;
/** Paragraph representing a perex of the document. It's equivalent to [abstract] and [lead].*/
static perex(text?: string): ParaSpec;
/** Paragraph containing a body of the document. It's equivalent to [text]. */
static body(text?: string): ParaSpec;
/** Paragraph containing a text of the document. It's equivalent to [body]. */
static text(text?: string): ParaSpec;
}
/**
* The linguistic analyses the G3 API can perform;
* [more detail][https://help.geneea.com/api_general/guide/analyses.html]
*/
export declare enum AnalysisType {
/** Perform all analyses at once */
ALL = "ALL",
/** Recognize and standardize entities in text;
* [more details][https://help.geneea.com/api_general/guide/entities.html]
*/
ENTITIES = "ENTITIES",
/** Assign semantic tags to a document.
* [more details][<https://help.geneea.com/api_general/guide/tags.html]
*/
TAGS = "TAGS",
/** Relations between entities and their attributes;
* [more details][<https://help.geneea.com/api_general/guide/relations.html]
*/
RELATIONS = "RELATIONS",
/** Detect the emotions of the author contained in the text;
* [more details][https://help.geneea.com/api_general/guide/sentiment.html]
*/
SENTIMENT = "SENTIMENT",
/** Detect the language the text is written in;
* [more details][https://help.geneea.com/api_general/guide/language.html]
*/
LANGUAGE = "LANGUAGE"
}
export declare const parseStrToAnalysisType: (typeStr: string) => AnalysisType;
/** Typically used ISO 639-1 language codes. */
export declare enum LanguageCode {
CS = "cs",
DE = "de",
EN = "en",
ES = "es",
PL = "pl",
SK = "sk"
}
/** Typically used domains. For more info [see][https://help.geneea.com/api_general/guide/domains.html] */
export declare enum Domain {
/** General media articles. */
MEDIA = "media",
/** Media articles covering news. */
NEWS = "news",
/** Media articles covering sport news. */
SPORT = "sport",
/** Tabloid articles. */
TABLOID = "tabloid",
/** Media articles covering technology and science. */
TECH = "tech",
/** General Voice-of-the customer documents (e.g. reviews). */
VOC = "voc",
/** Voice-of-the customer documents covering banking (e.g. reviews of banks). */
VOC_BANKING = "voc-banking",
/** Voice-of-the customer documents covering restaurants (e.g. reviews of restaurants). */
VOC_HOSPITALITY = "voc-hospitality"
}
/** Typically used text types. */
export declare enum TextType {
/** Text that is mostly grammatically, orthographically and typographically correct, e.g. news articles. */
CLEAN = "clean",
/** Text that ignores many formal grammatical, orthographical and typographical conventions,
* e.g. social media posts.
*/
CASUAL = "casual"
}
/** Supported diacritization models. */
export declare enum Diacritization {
/** No diacritization is performed. */
NONE = "none",
/** Diacritics is added if needed. */
AUTO = "auto",
/** Diacritics is added to words without it if needed. */
YES = "yes",
/** Diacritics is first removed and then added if needed. */
REDO = "redo"
}
/**
* An object encapsulating a single REST request for the G3 API.
*/
export declare class Request {
readonly id: string | null;
readonly title: string | null;
readonly text: string | null;
readonly paraSpecs: ParaSpec[] | null;
readonly language: string | null;
readonly langDetectPrior: string | null;
readonly domain: string | null;
readonly textType: string | null;
readonly referenceDate: string | null;
readonly diacritization: string | null;
readonly returnMentions: boolean | null;
readonly returnItemSentiment: boolean | null;
readonly metadata: Map<string, string> | null;
readonly customConfig: Map<string, unknown | null> | null;
readonly analyses: Set<AnalysisType> | null;
/**
*
* @param id Unique identifier of the document.
* @param title The title or subject of the document, when available; mutually exclusive with the ``paraSpecs`` parameter.
* @param text The main text of the document; mutually exclusive with the ``paraSpecs`` parameter.
* @param paraSpecs The document paragraphs; mutually exclusive with the `title` and `text` parameters.
* @param analyses What analyses to return.
* @param language The language of the document as ISO 639-1; auto-detection will be used if omitted.
* @param langDetectPrior The language detection prior; e.g. ‘de,en’.
* @param domain The source domain from which the document originates.
* See the [available domains][https://help.geneea.com/api_general/guide/domains.html]
* @param textType The type or genre of text; not supported in public workflows/domains yet.
* @param referenceDate Date to be used for the analysis as a reference; values: “NOW” or in format YYYY-MM-DD.
* @param diacritization Determines whether to perform text diacritization.
* @param returnMentions Should entity/tag/relation mentions be returned? No mentions are returned if null.
* @param returnItemSentiment Should entity/mention/tag/relation etc. sentiment be returned? No sentiment is returned if null.
* @param metadata Extra non-NLP type of information related to the document, key-value pairs.
* @param customConfig
*/
constructor(id?: string | null, title?: string | null, text?: string | null, paraSpecs?: ParaSpec[] | null, analyses?: AnalysisType[] | null, language?: string | null, langDetectPrior?: string | null, domain?: string | null, textType?: string | null, referenceDate?: string | null, diacritization?: string | null, returnMentions?: boolean | null, returnItemSentiment?: boolean | null, metadata?: Map<string, string> | null, customConfig?: Map<string, unknown | null> | null);
/** Converts a request instance to a JSON compatible object. */
toJson(): unknown;
/** Converts a request instance to a JSON string. */
toJsonString(): string;
/** Reads a request instance from a JSON object. */
static fromJson(raw: any): Request;
}
/**
* An interface for objects to be passed to RequestBuilder's build() method.
*
* @member id Unique identifier of the document.
* @member text The main text of the document; mutually exclusive with the ``paraSpecs`` parameter.
* @member title The title or subject of the document, when available; mutually exclusive with the ``paraSpecs`` parameter.
* @member paraSpecs The document paragraphs; mutually exclusive with `title` and `text` parameters.
* @member language The language of the document as ISO 639-1; auto-detection will be used if null.
* @member referenceDate Date to be used for the analysis as a reference; values: ``NOW`` or in format YYYY-MM-DD.
* No reference date is used if null.
* @member metadata Extra non-NLP type of information related to the document, key-value pairs.
* @member customConfig Any custom options passed to the G3 API endpoint.
*/
export interface RequestOptions {
id?: string;
text?: string;
title?: string;
paraSpecs?: ParaSpec[];
language?: string;
referenceDate?: string;
metadata?: Map<string, string>;
customConfig?: Map<string, unknown | null>;
}
/**
* Creates a builder with fields meant to be shared across requests.
*
* When analyzing multiple documents, one should:
* * first, create a builder specifying all parameters shared by all the analyses to perform (e.g. [analyses] to perform,
* [language prior][langDetectPrior]),
* * then, use the build function to create individual requests specifying the parameters that are specific
* for the analysis of each document (Id and text of the document, but possibly also `language`, etc).
*/
export declare class RequestBuilder {
private _analyses;
private _language;
private _langDetectPrior;
private _domain;
private _textType;
private _referenceDate;
private _diacritization;
private _returnMentions;
private _returnItemSentiment;
private _metadata;
private _customConfig;
/** What analyses to return */
get analyses(): AnalysisType[] | null;
/** What analyses to return */
set analyses(analyses: AnalysisType[] | null);
/** The language of the document as ISO 639-1; auto-detection will be used if omitted. */
get language(): string | null;
/** The language of the document as ISO 639-1; auto-detection will be used if omitted. */
set language(language: string | LanguageCode | null);
/** The language detection prior; e.g. ‘de,en’. */
get langDetectPrior(): string | null;
/** The language detection prior; e.g. ‘de,en’. */
set langDetectPrior(langDetectPrior: string | null);
/** The source domain from which the document originates.
* See the [available domains][https://help.geneea.com/api_general/guide/domains.html]
*/
get domain(): string | null;
/** The source domain from which the document originates.
* See the [available domains][https://help.geneea.com/api_general/guide/domains.html]
*/
set domain(domain: string | Domain | null);
/** The type or genre of text; not supported in public workflows/domains yet. */
get textType(): string | null;
/** The type or genre of text; not supported in public workflows/domains yet. */
set textType(textType: string | TextType | null);
/** Date to be used for the analysis as a reference; either “NOW” or in format YYYY-MM-DD. */
get referenceDate(): string | null;
/** Date to be used for the analysis as a reference; either “NOW” or in format YYYY-MM-DD. */
set referenceDate(referenceDate: string | null);
/** Determines whether to perform text diacritization */
get diacritization(): string | null;
/** Determines whether to perform text diacritization */
set diacritization(diacritization: string | Diacritization | null);
/** Should entity/tag/relation mentions be returned? No mentions are returned if null. */
get returnMentions(): boolean | null;
/** Should entity/tag/relation mentions be returned? No mentions are returned if null. */
set returnMentions(returnMentions: boolean | null);
/** Should entity/mention/tag/relation etc. sentiment be returned? No sentiment is returned if null. */
get returnItemSentiment(): boolean | null;
/** Should entity/mention/tag/relation etc. sentiment be returned? No sentiment is returned if null. */
set returnItemSentiment(returnItemSentiment: boolean | null);
/** Extra non-NLP type of information related to the document, key-value pairs. */
get metadata(): Map<string, string> | null;
/** Extra non-NLP type of information related to the document, key-value pairs. */
set metadata(metadata: Map<string, string> | null);
/**
* Add [custom options][customConfig] to the request builder to be passed to the G3 API endpoint.
* Existing custom options are overwritten.
*/
get customConfig(): Map<string, unknown | null> | null;
/**
* Add [custom options][customConfig] to the request builder to be passed to the G3 API endpoint.
* Existing custom options are overwritten.
*/
set customConfig(customConfig: Map<string, unknown | null> | null);
private formatRefDate;
private parseRefDate;
/**
* Creates a new request object to be passed to the G3 client.
*
* @param options A RequestOptions object.
* @returns Request object to be passed to the G3 client.
*/
build(options: RequestOptions): Request;
}