diff --git a/src/word.ts b/src/word.ts index fe61679..13099a1 100644 --- a/src/word.ts +++ b/src/word.ts @@ -221,4 +221,15 @@ export class Word { get isNotHebrew(): boolean { return !this.clusters.map((c) => c.isNotHebrew).includes(false); } + + /** + * Returns `true` if the Word is in a construct state + * + * @description + * The construct state is indicated by the presence of a maqqef (U+05BE) character + */ + get isInConstruct(): boolean { + // if word has a maqqef, it is in construct + return this.text.includes("\u05BE"); + } } diff --git a/test/word.test.ts b/test/word.test.ts index 3193b7c..9dca87e 100644 --- a/test/word.test.ts +++ b/test/word.test.ts @@ -50,3 +50,14 @@ describe.each` }); }); }); + +describe.each` + description | heb | isInConstructArray + ${"with maqqef"} | ${"בֶּן־אָדָ֕ם"} | ${[true, false]} + ${"now maqqef"} | ${"בֶּן אָדָ֕ם"} | ${[false, false]} +`("isInConstruct:", ({ description, heb, isInConstructArray }) => { + const text = new Text(heb); + test(`${description}`, () => { + expect(text.words.map((word) => word.isInConstruct)).toEqual(isInConstructArray); + }); +});