Skip to content

Commit

Permalink
Merge pull request #146 from charlesLoder/telisha-qetana
Browse files Browse the repository at this point in the history
Telisha qetana
  • Loading branch information
charlesLoder authored Nov 1, 2023
2 parents a8b8ee5 + e52bafe commit 20a9f4d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/utils/syllabifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ const setIsClosed = (syllable: Syllable, index: number, arr: Syllable[]) => {
};

const setIsAccented = (syllable: Syllable) => {
if (syllable.isAccented) {
return;
}
// TODO: this is pretty hacky, but it works; find a more elegant solution
const jerusalemFinal = /\u{5B4}\u{05DD}/u;
const jerusalemPrev = /ל[\u{5B8}\u{5B7}]/u;
Expand All @@ -378,6 +381,33 @@ const setIsAccented = (syllable: Syllable) => {
prev = (prev?.prev?.value as Syllable) ?? null;
}
}

// the telisha qetana is a postpositive accent
const telishaQetana = /\u{05A9}/u;
if (telishaQetana.test(syllable.text) && prev) {
// if the telisha qetana is preceded by a telisha qetana, then the previous syllable is accented
// e.g. the last syllable in וְהֵסִ֩ירָה֩
if (telishaQetana.test(prev.text)) {
prev.isAccented = true;
return;
}

// if the telisha qetana is followed by a telisha qetana, then the current syllable is accented
// e.g. the penultimate syllable in וְהֵסִ֩ירָה֩
const next = syllable.next?.value;
if (next && telishaQetana.test(next.text)) {
syllable.isAccented = true;
return;
}

// if none of the above, then this is a standard telisha qetana
// e.g. the final syllable in וַיֹּאמֶר֩
if (!telishaQetana.test(prev.text)) {
prev.isAccented = true;
return;
}
}

const isAccented = syllable.clusters.filter((cluster) => (cluster.hasTaamim || cluster.hasSilluq ? true : false))
.length
? true
Expand Down
4 changes: 3 additions & 1 deletion test/syllabification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe.each`
${"final he"} | ${"מַלְכָּ֔ה"} | ${["מַלְ", "כָּ֔ה"]} | ${[true, false]} | ${[false, true]}
${"single syllable, final he"} | ${"פֹּ֖ה"} | ${["פֹּ֖ה"]} | ${[false]} | ${[true]}
${"with single pashta"} | ${"לָאוֹר֙"} | ${["לָ", "אֹור֙"]} | ${[false, true]} | ${[false, true]}
${"with pashta and qadma"} | ${"תֹ֨הוּ֙"} | ${["תֹ֨", "הוּ֙"]} | ${[false, false]} | ${[true, false]}
`("2 Syllables:", ({ description, original, sylArr, closedArr, accentArr }) => {
tests(description, original, sylArr, closedArr, accentArr);
});
Expand All @@ -63,7 +64,7 @@ describe.each`
${"word and passeq"} | ${"דָּבָ֗ר ׀"} | ${["דָּ", "בָ֗ר", "׀"]} | ${[false, true, true]} | ${[false, true, true]}
${"segolate noun"} | ${"הָאָֽרֶץ׃"} | ${["הָ", "אָֽ", "רֶץ׃"]} | ${[false, false, true]} | ${[false, true, false]}
${"with pashta and pastha"} | ${"הַמַּ֙יִם֙"} | ${["הַ", "מַּ֙", "יִם֙"]} | ${[true, false, true]} | ${[false, true, false]}
${"with pashta and qadma"} | ${"תֹ֨הוּ֙"} | ${["תֹ֨", "הוּ֙"]} | ${[false, false]} | ${[true, false]}
${"with one telisha qetana"} | ${"וַיֹּאמֶר֩"} | ${["וַ", "יֹּא", "מֶר֩"]} | ${[true, false, true]} | ${[false, true, false]}
`("3 Syllables:", ({ description, original, sylArr, closedArr, accentArr }) => {
tests(description, original, sylArr, closedArr, accentArr);
});
Expand All @@ -76,6 +77,7 @@ describe.each`
${"Jerusalem w/ patah"} | ${"יְרוּשָׁלִַ֗ם"} | ${["יְ", "רוּ", "שָׁ", "לַ֗", "ִם"]} | ${[false, false, false, false, true]} | ${[false, false, false, true, false]}
${"Jerusalem w/ qamets"} | ${"בִּירוּשָׁלִָֽם׃"} | ${["בִּי", "רוּ", "שָׁ", "לָֽ", "ִם׃"]} | ${[false, false, false, false, true]} | ${[false, false, false, true, false]}
${"aleph w/ shureq"} | ${"יִירָא֥וּךָ"} | ${["יִי", "רָ", "א֥וּ", "ךָ"]} | ${[false, false, false, false]} | ${[false, false, true, false]}
${"with two telisha qetana"} | ${"וְהֵסִ֩ירָה֩"} | ${["וְ", "הֵ", "סִ֩י", "רָה֩"]} | ${[false, false, false, false]} | ${[false, false, true, false]}
`("4 Syllables:", ({ description, original, sylArr, closedArr, accentArr }) => {
tests(description, original, sylArr, closedArr, accentArr);
});

0 comments on commit 20a9f4d

Please sign in to comment.