UNPKG

geneea-nlp-client

Version:

The TypeScript Client for Geneea Interpretor G3 API.

83 lines (82 loc) 3.96 kB
import { HasId } from "../../common/id"; import { Entity } from "./entity"; import { HasSentiment, Sentiment } from "./sentiment"; import { TectoToken } from "./tecto-token"; import { TokenSupport, Token } from "./token"; import { HasVectors, Vector } from "./vector"; /** An object encapsulating a relation extracted from text. For example `buy(John, car)`. */ declare class Relation implements HasId, HasSentiment, HasVectors { readonly id: string; textRepr: string; name: string; type: string; args: RelationArgument[]; support: RelationSupport[]; feats: Map<string, string>; sentiment: Sentiment | null; vectors: Vector[] | null; /** Attribute relation (e.g. `good(pizza)` for _good pizza_, _pizza is good_). */ static readonly TYPE_ATTR = "attr"; /** Verbal relation (e.g. `eat(pizza)` for _eat a pizza_. */ static readonly TYPE_RELATION = "relation"; /** * Relation where at least one argument is outside of the the document (e.g. between `pizza` in the document and * `food` item in the knowledgebase). */ static readonly TYPE_EXTERNAL = "external"; /** Key presence signifies it is a negated word, value = True.*/ static readonly FEAT_NEGATED = "negated"; /** Feature storing info about modality. */ static readonly FEAT_MODALITY = "modality"; /** * * @param id ID of the relation used to refer to it from other objects. * @param textRepr Human redable representation of the relation, e.g. `eat-not(SUBJ:John, DOBJ:pizza)`. * @param name Name of the relation, e.g. `eat` for _eat a pizza_ or `good` for _a good pizza_. * @param type One of Relation.TYPE_ATTR, Relation.TYPE_RELATION, Relation.TYPE_EXTERNAL. * @param args Arguments of the relation (subject, possibly an object). * @param support Tecto-tokens of all the mentions of the relations (restricted to its head). Empty if not requested. * @param feats Any features of the relation e.g. modality: can. * @param sentiment Sentiment of this relation. null if not requested. * @param vectors Optional vectors for this relation. */ private constructor(); /** Relation factory method, public constructor. */ static of(id: string, textRepr: string, name: string, type: string, args: RelationArgument[], support?: RelationSupport[] | null, feats?: Map<string, string> | null, sentiment?: Sentiment | null, vectors?: Vector[] | null): Relation; isNegated(): boolean; modality(): string | null; /** Returns the relation subject argument, if precisely one is present; otherwise returns null. */ subj(): RelationArgument | null; /** Returns the relation object argument, if precisely one is present; otherwise returns null. */ obj(): RelationArgument | null; toString(): string; } /** Object representing an argument (subject/object) of a relation. */ declare class RelationArgument { name: string; type: string; entity: Entity | null; /** * * @param name Name of the argument (e.g. John). * @param type Type of the argument (subject, object). * @param entity The entity corresponding to this argument, if any. null if the argument is not an entity. */ constructor(name: string, type: string, entity: Entity | null); toString(): string; } /** Tokens corresponding to a single head (predicate) of a relation. */ declare class RelationSupport { tokens: TokenSupport; tectoToken: TectoToken | null; /** * * @param tokens Tokens corresponding to the head of the relation. * @param tectoToken Tecto token corresponding to the tokens. null if tecto tokens are not part of the model. */ private constructor(); /** RelationSupport factory method, public constructor. */ static of(tokens: Token[], tectoToken?: TectoToken | null): RelationSupport; toString(): string; } export { Relation, RelationArgument, RelationSupport };