geneea-nlp-client
Advanced tools
Comparing version 0.3.3 to 1.1.0
@@ -37,2 +37,3 @@ "use strict"; | ||
]); | ||
const RE_FULL_DEP_FNC = /^([a-z]+):([a-z]+)$/i; | ||
class Reader { | ||
@@ -116,9 +117,24 @@ constructor() { | ||
const pos = raw.pos ? __1.UPosFromStr(raw.pos) : null; | ||
const fnc = raw.fnc | ||
? raw.fnc.toUpperCase() === "CLAUSE" | ||
? __1.UDep.ROOT | ||
: __1.UDepFromStr(raw.fnc) | ||
: null; | ||
const fncStr = raw.fnc; | ||
let fnc = null; | ||
let subFnc = null; | ||
if (fncStr) { | ||
if (fncStr.toUpperCase() === "CLAUSE") { | ||
fnc = __1.UDep.ROOT; | ||
subFnc = null; | ||
} | ||
else { | ||
const matches = fncStr.match(RE_FULL_DEP_FNC); | ||
if (matches !== null) { | ||
fnc = __1.UDepFromStr(matches[1]); | ||
subFnc = matches[2]; | ||
} | ||
else { | ||
fnc = __1.UDepFromStr(fncStr); | ||
subFnc = null; | ||
} | ||
} | ||
} | ||
const tok = model_1.Token.of(raw.id, tokenIdx, // sentence based index | ||
text, char_span_1.CharSpan.withLen(off, text.length), origText, char_span_1.CharSpan.withLen(origOff, origText.length), raw.dLemma, raw.lemma, pos, raw.mTag, raw.feats ? this.readFeats(raw.feats) : null, fnc); | ||
text, char_span_1.CharSpan.withLen(off, text.length), origText, char_span_1.CharSpan.withLen(origOff, origText.length), raw.dLemma, raw.lemma, pos, raw.mTag, raw.feats ? this.readFeats(raw.feats) : null, fnc, subFnc); | ||
this.register(tok); | ||
@@ -125,0 +141,0 @@ return tok; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const offset_converter_1 = require("../../common/offset-converter"); | ||
const udep_1 = require("../../common/udep"); | ||
const upos_1 = require("../../common/upos"); | ||
@@ -99,3 +98,3 @@ const common_1 = require("../../common/common"); | ||
if (t.fnc) | ||
obj.fnc = udep_1.UDepToStr(t.fnc); | ||
obj.fnc = t.fullFnc; | ||
if (t.parent) | ||
@@ -102,0 +101,0 @@ obj.parId = t.parent.id; |
@@ -37,2 +37,4 @@ import { CharSpan } from "../../common/char-span"; | ||
fnc: UDep | null; | ||
/** Dependency sub-function. None if not requested/supported. */ | ||
subFnc: string | null; | ||
/** Lemma info features, a list of strings. */ | ||
@@ -46,3 +48,3 @@ static readonly FEAT_LEMMA_INFO = "lemmaInfo"; | ||
/** Token factory method, public constructor. */ | ||
static of(id: string, idx: number, text: string, charSpan: CharSpan, origText?: string | null, origCharSpan?: CharSpan | null, deepLemma?: string | null, lemma?: string | null, pos?: UPos | null, morphTag?: string | null, feats?: Map<string, string> | null, fnc?: UDep | null): Token; | ||
static of(id: string, idx: number, text: string, charSpan: CharSpan, origText?: string | null, origCharSpan?: CharSpan | null, deepLemma?: string | null, lemma?: string | null, pos?: UPos | null, morphTag?: string | null, feats?: Map<string, string> | null, fnc?: UDep | null, subFnc?: string | null): Token; | ||
/** True iff the token form contains a negation prefix. */ | ||
@@ -63,2 +65,7 @@ isNegated(): boolean; | ||
next(): Token | null; | ||
/** | ||
* Full dependency function in the format `{fnc}:{subFnc}` if the sub-function is present. | ||
* Otherwise it's the same as `fnc`. | ||
*/ | ||
get fullFnc(): string | null; | ||
/** Converts the token to a default non-recursive string: index + text. */ | ||
@@ -65,0 +72,0 @@ toSimpleString(): string; |
@@ -6,2 +6,3 @@ "use strict"; | ||
const common_1 = require("../../common/common"); | ||
const udep_1 = require("../../common/udep"); | ||
const node_1 = require("./node"); | ||
@@ -36,3 +37,5 @@ /** | ||
/** Label of the dependency edge. Null if not requested/supported. */ | ||
fnc) { | ||
fnc, | ||
/** Dependency sub-function. None if not requested/supported. */ | ||
subFnc) { | ||
super(); | ||
@@ -51,8 +54,9 @@ this.id = id; | ||
this.fnc = fnc; | ||
this.subFnc = subFnc; | ||
} | ||
/** Token factory method, public constructor. */ | ||
static of(id, idx, text, charSpan, origText = null, origCharSpan = null, deepLemma = null, lemma = null, pos = null, morphTag = null, feats = null, fnc = null) { | ||
static of(id, idx, text, charSpan, origText = null, origCharSpan = null, deepLemma = null, lemma = null, pos = null, morphTag = null, feats = null, fnc = null, subFnc = null) { | ||
return new Token(id, idx, text, charSpan, origText === null || text === origText ? text : origText, origCharSpan === null || charSpan === origCharSpan | ||
? charSpan | ||
: origCharSpan, deepLemma, lemma, pos, morphTag, feats !== null && feats !== void 0 ? feats : new Map(), fnc); | ||
: origCharSpan, deepLemma, lemma, pos, morphTag, feats !== null && feats !== void 0 ? feats : new Map(), fnc, subFnc); | ||
} | ||
@@ -86,2 +90,14 @@ /** True iff the token form contains a negation prefix. */ | ||
} | ||
/** | ||
* Full dependency function in the format `{fnc}:{subFnc}` if the sub-function is present. | ||
* Otherwise it's the same as `fnc`. | ||
*/ | ||
get fullFnc() { | ||
if (this.fnc !== null) { | ||
const fnc = udep_1.UDepToStr(this.fnc); | ||
return this.subFnc !== null ? `${fnc}:${this.subFnc}` : fnc; | ||
} | ||
else | ||
return null; | ||
} | ||
/** Converts the token to a default non-recursive string: index + text. */ | ||
@@ -113,2 +129,3 @@ toSimpleString() { | ||
"fnc", | ||
"subFnc", | ||
]); | ||
@@ -115,0 +132,0 @@ } |
{ | ||
"name": "geneea-nlp-client", | ||
"version": "0.3.3", | ||
"version": "1.1.0", | ||
"description": "The TypeScript Client for Geneea Interpretor G3 API.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
175905
4282
0