Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stress #150

Merged
merged 2 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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