geneea-nlp-client
Version:
The TypeScript Client for Geneea Interpretor G3 API.
66 lines (65 loc) • 2.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Paragraph = void 0;
const common_1 = require("../../common/common");
class Paragraph {
/**
*
* @param id ID of the paragraph used to refer to it from other objects.
* @param type Title, section heading, lead, body text, etc. For now, it is simply the segment type: title, lead, body.
* @param text The paragraph text, possibly after correction (token offsets link here).
* @param origText The original paragraph text as in the request.
* @param sentences The sentences the paragraph consists of.
* @param sentiment Optional sentiment of the paragraph.
* @param vectors Optional vectors for this paragraph.
*/
constructor(id, type, text, origText, sentences, sentiment, vectors) {
this.id = id;
this.type = type;
this.text = text;
this.origText = origText;
this.sentences = sentences;
this.sentiment = sentiment;
this.vectors = vectors;
}
/** Paragraph factory method, public constructor. */
static of(id, type, text, origText = null, sentences = null, sentiment = null, vectors = null) {
return new Paragraph(id, type, text, origText === null || text === origText ? text : origText, sentences !== null && sentences !== void 0 ? sentences : [], sentiment, vectors);
}
/** Tokens across all sentences. */
*tokens() {
for (const s of this.sentences) {
for (const t of s.tokens)
yield t;
}
}
/** Tecto tokens across all sentences. */
*tectoTokens() {
for (const s of this.sentences) {
if (s.tectoTokens !== null) {
for (const tt of s.tectoTokens)
yield tt;
}
}
}
toString() {
return (0, common_1.objToStr)(this, [
"id",
"type",
"text",
"origText",
"sentences",
"sentiment",
"vectors",
]);
}
}
exports.Paragraph = Paragraph;
/** Type of a paragraph representing a title of the whole document. Also used for email subjects. */
Paragraph.TYPE_TITLE = "TITLE";
/** Type of a paragraph representing an abstract (lead or perex) of the whole document. */
Paragraph.TYPE_ABSTRACT = "ABSTRACT";
/** Type of a paragraph containing regular text (for now this is used for the whole body of the document). */
Paragraph.TYPE_BODY = "BODY";
/** Type of a paragraph representing a section/chapter heading (not used yet). */
Paragraph.TYPE_SECTION_HEADING = "section_heading";