Skip to content

Commit

Permalink
Add logic for final syllable when word is in construct
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Loder committed Dec 30, 2023
1 parent 7b9cad8 commit cf84f95
Show file tree
Hide file tree
Showing 2 changed files with 4 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

0 comments on commit cf84f95

Please sign in to comment.