geneea-nlp-client
Version:
The TypeScript Client for Geneea Interpretor G3 API.
98 lines (97 loc) • 4.17 kB
TypeScript
import { Entity } from "./entity";
import { Language } from "./language";
import { Paragraph } from "./paragraph";
import { Relation } from "./relation";
import { Sentence } from "./sentence";
import { HasSentiment, Sentiment } from "./sentiment";
import { Tag } from "./tag";
import { TectoToken } from "./tecto-token";
import { Token } from "./token";
import { HasVectors, Vector } from "./vector";
/** An object encapsulating the results of NLP analysis. */
declare class Analysis implements HasSentiment, HasVectors {
docId: string | null;
language: Language;
paragraphs: Paragraph[];
docSentiment: Sentiment | null;
entities: Entity[];
tags: Tag[];
relations: Relation[];
docVectors: Vector[] | null;
usedChars: number | null;
metadata: Map<string, unknown> | null;
debugInfo: unknown;
/**
* Creates an Analysis object.
* @param docId Document id.
* @param language Language of the document and analysis.
* @param paragraphs The paragraphs within the document. For F2, these are segments.
* @param docSentiment Sentiment of the document.
* @param entities The entities in the document.
* @param tags The tags of the document.
* @param relations The relations in the document.
* @param docVectors Optional vectors for the whole document.
* @param usedChars Characters billed for the analysis.
* @param metadata The extra non-NLP type of information related to analysis.
* @param debugInfo Debugging information, if any.
*/
constructor(docId: string | null | undefined, language: Language, paragraphs: Paragraph[], docSentiment: (Sentiment | null) | undefined, entities: Entity[], tags: Tag[], relations: Relation[], docVectors?: Vector[] | null, usedChars?: number | null, metadata?: Map<string, unknown> | null, debugInfo?: unknown);
get id(): string;
get sentiment(): Sentiment | null;
get vectors(): Vector[] | null;
/** Sentences across all paragraphs. */
sentences(): Iterable<Sentence>;
/** Tokens across all paragraphs. */
tokens(): Iterable<Token>;
/** Tecto tokens across all paragraphs. */
tectoTokens(): Iterable<TectoToken>;
/** Returns the top [n] tags sorted by `relevance` in descending order. */
topTags(n?: number): Tag[];
/**
* Returns a paragraph with the specified type.
* Throws IllegalArgumentException if there are more than one such paragraphs, and return null if there are none.
* This is intended for legacy paragraphs corresponding to title/lead/text segments.
*
* For standard types, use these predefined constants:
* [Paragraph.TYPE_TITLE], [Paragraph.TYPE_ABSTRACT], [Paragraph.TYPE_BODY], [Paragraph.TYPE_SECTION_HEADING],
* or dedicated methods: [title], [lead], [body].
*/
getParaByType(paraType: string): Paragraph | null;
/**
* Returns the title paragraph if present, null if not, and throws
* an error if there are multiple title paragraphs.
*/
titlePara(): Paragraph | null;
/**
* Returns the title paragraph if present, null if not, and throws
* an error if there are multiple subject paragraphs.
*/
subjectPara(): Paragraph | null;
/**
* Returns the title paragraph if present, null if not, and throws
* an error if there are multiple abstract paragraphs.
*/
abstractPara(): Paragraph | null;
/**
* Returns the title paragraph if present, null if not, and throws
* an error if there are multiple lead paragraphs.
*/
leadPara(): Paragraph | null;
/**
* Returns the title paragraph if present, null if not, and throws
* an error if there are multiple perex paragraphs.
*/
perexPara(): Paragraph | null;
/**
* Returns the title paragraph if present, null if not, and throws
* an error if there are multiple body paragraphs.
*/
bodyPara(): Paragraph | null;
/**
* Returns the title paragraph if present, null if not, and throws
* an error if there are multiple text paragraphs.
*/
textPara(): Paragraph | null;
toString(): string;
}
export { Analysis };