geneea-nlp-client
Version:
The TypeScript Client for Geneea Interpretor G3 API.
99 lines (98 loc) • 3.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TagMention = exports.Tag = void 0;
const common_1 = require("../../common/common");
const token_1 = require("./token");
class Tag {
/**
*
* @param id ID of the tag used to refer to it from other objects.
* @param gkbId Unique identifier of this tag in Geneea knowledge-base. null if not found.
* @param stdForm Standard form of the tag, abstracting from its alternative names.
* @param type Domain-specific type (e.g. content, theme, iAB, department).
* @param relevance Relevance of the tag relative to the content of the document.
* @param mentions Text segments related to this tag. Empty if not appropriate/requested/supported.
* @param feats Custom features.
* @param sentiment Sentiment of this tag. Not supported yet.
* @param vectors Optional vectors for this tag.
* @param gkbProperties GKB properties. Since 3.3.0.
*/
constructor(id, gkbId, stdForm, type, relevance, mentions, feats, sentiment, vectors, gkbProperties) {
this.id = id;
this.gkbId = gkbId;
this.stdForm = stdForm;
this.type = type;
this.relevance = relevance;
this.mentions = mentions;
this.feats = feats;
this.sentiment = sentiment;
this.vectors = vectors;
this.gkbProperties = gkbProperties;
}
/** Tag factory method, public constructor. */
static of(id, gkbId, stdForm, type, relevance, mentions = null, feats = null, sentiment = null, vectors = null, gkbProperties = null) {
return new Tag(id, gkbId, stdForm, type, relevance, mentions !== null && mentions !== void 0 ? mentions : [], feats !== null && feats !== void 0 ? feats : new Map(), sentiment, vectors, gkbProperties !== null && gkbProperties !== void 0 ? gkbProperties : []);
}
toString() {
return (0, common_1.objToStr)(this, [
"id",
"gkbId",
"stdForm",
"type",
"relevance",
"feats",
"mentions",
"sentiment",
"vectors",
"gkbProperties",
]);
}
}
exports.Tag = Tag;
/** Type of the tag with the main topic of the document */
Tag.TYPE_TOPIC = "topic";
/** Type of the tags with the topic distribution of the document */
Tag.TYPE_TOPIC_DISTRIBUTION = "topic.distribution";
/** A single occurence of a tag in the text. */
class TagMention {
/**
*
* @param id ID of the mention used to refer to it from other objects.
* @param tokens Tokens of this tag mention.
* @param feats Custom features/properties.
* @param sentiment Sentiment of this mention. Not supported yet.
* @param vectors Optional vectors for this tag mention.
*/
constructor(id, tokens, feats, sentiment, vectors) {
this.id = id;
this.tokens = tokens;
this.feats = feats;
this.sentiment = sentiment;
this.vectors = vectors;
}
/** TagMention factory method, public constructor. */
static of(id, tokens, feats = null, sentiment = null, vectors = null) {
return new TagMention(id, token_1.TokenSupport.of(tokens), feats !== null && feats !== void 0 ? feats : new Map(), sentiment, vectors);
}
/**
* Sentence containing this tag mention.
* Tag mention belongs to maximally one sentence; artificial mentions without tokens belong to no sentence.
*/
sentence() {
return this.tokens.sentence;
}
/** Checks whether the tag mention is continuous (most are). */
isContinuous() {
return this.tokens.isContinuous;
}
toString() {
return (0, common_1.objToStr)(this, [
"id",
"tokens",
"feats",
"sentiment",
"vectors",
]);
}
}
exports.TagMention = TagMention;