charlesLoder / havarotjs

A Typescript package for getting syllabic data about Hebrew text with niqqud.
https://www.npmjs.com/package/havarotjs
MIT License
12 stars 4 forks source link

`longVowels` incorrect with holam male #121

Closed charlesLoder closed 1 year ago

charlesLoder commented 1 year ago

See initial discussion here.

In a word like "הוֹלְכִים" when longVowels is false it should be a 2 syllable word.

const str = "הוֹלְכִים";
const result = new Text(str, { longVowels: false }).syllables.map((s) => s.text);
// [ 'הֹו', 'לְ', 'כִים' ]

But it should be

// correct
// [ 'הֹולְ', 'כִים' ]
JacobWeinbren commented 1 year ago

@charlesLoder

Hi - hopefully this simple change to syllabifier.ts helps.

if (shevaPresent && cluster.hasLongVowel) {
  if (options.longVowels) {
    syl = shevaNewSyllable(syl);
    result.push(cluster);
    shevaPresent = false;
  } else {
    // If longVowels is false, don't create a new syllable, just add the cluster to the current syllable
    syl.unshift(cluster);
    shevaPresent = false;
  }
  continue;
}
JacobWeinbren commented 1 year ago

@charlesLoder Oh - I see what you are asking. Apologies.

Is this the fix you are looking for?

get hasLongVowel(): boolean {
    return /[\u{05B5}\u{05B8}\u{05B9}\u{05BA}\u05B9]/u.test(this.text);
}

This just checks for a holam.

https://github.com/charlesLoder/havarotjs/blob/1bd2cc092d4680a9c936eb4c3fece2cc8e0993c0/src/cluster.ts#L237