Skip to content

Commit

Permalink
Merge pull request #150 from charlesLoder/fix-stress
Browse files Browse the repository at this point in the history
Fix stress
  • Loading branch information
charlesLoder authored Dec 30, 2023
2 parents b8e40ef + cf84f95 commit 84a7a12
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/utils/syllabifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ const reinsertLatin = (syls: Syllable[], latin: { cluster: Cluster; pos: number
return syls;
};

export const syllabify = (clusters: Cluster[], options: SylOpts): Syllable[] => {
export const syllabify = (clusters: Cluster[], options: SylOpts, isWordInConstruct: boolean): Syllable[] => {
const removeLatin = clusters.filter((cluster) => !cluster.isNotHebrew);
const latinClusters = clusters.map(clusterPos).filter((c) => c.cluster.isNotHebrew);
const groupedClusters = groupClusters(removeLatin, options);
Expand All @@ -530,7 +530,8 @@ export const syllabify = (clusters: Cluster[], options: SylOpts): Syllable[] =>
syllables.forEach(setIsAccented);

// if there is no accented syllable, then the last syllable is accented
if (!syllables.map((s) => s.isAccented).includes(true)) {
// unless that syllable is part of a word in construct
if (!syllables.map((s) => s.isAccented).includes(true) && !isWordInConstruct) {
syllables[syllables.length - 1].isAccented = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/word.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class Word {
return [syl];
}

const syllables = syllabify(this.clusters, this.sylOpts);
const syllables = syllabify(this.clusters, this.sylOpts, this.isInConstruct);
syllables.forEach((syl) => (syl.word = this));

return syllables;
Expand Down
4 changes: 4 additions & 0 deletions test/syllable.isAccented.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ describe("Test if a syllable is accented", () => {
testIsAccented("דָּבָר", [false, true]);
});

test("If in construct, no accent", () => {
testIsAccented("כָּל־הָעָ֖ם", [false, false, true]);
});

describe("Taamim that fall on the stressed syllable", () => {
test("silluq", () => {
testIsAccented("חֽוּשָׁה׃", [true, false]);
Expand Down

0 comments on commit 84a7a12

Please sign in to comment.