charlesLoder / hebrew-transliteration

A tool for transliterating Hebrew
https://www.npmjs.com/package/hebrew-transliteration
MIT License
37 stars 14 forks source link

SHEVA in Schema #63

Closed Zalexei closed 1 year ago

Zalexei commented 1 year ago

I'm trying to change scheme to be able to produce IPA representation. Could you please recommend how to deal with SHEVA Diphthong: usually it should be represented as empty sound, but in some words like 'מְתוּקִים' 'נְקֻדָּה' 'צְהֻבִּים' it should act as 'e'. Haven't found the way to differentiate cases - or it's very specific?

Also what is the best way to define j sound ('ג'ון') - as additional_feature?

Zalexei commented 1 year ago

Sorry, wasn't attentive to details: found example with exact problem in the documentation. Do you know what can be the problem that instead of replacing by result of function it replaces it with function body code:


// const rules = require("hebrew-transliteration/dist/rules"); // causes error - not exported
const transliterate = heb.transliterate;

console.log(heb.transliterate("בְּרֵאשִׁ֖ית וַיַּבְדֵּל", {
    ADDITIONAL_FEATURES: [
      {
        // matches any sheva in a syllable that is NOT preceded by a vowel character
        HEBREW: "(?<![\u{05B1}-\u{05BB}\u{05C7}].*)\u{05B0}",
        FEATURE: "syllable",
        TRANSLITERATION: function (syllable: { next: any; text: string; }, _hebrew: any, schema: { [x: string]: string; }) {
          const next = syllable.next;
          // ensure type safety
          const nextVowel = next.vowelName === "SHEVA" ? "VOCAL_SHEVA" : next.vowelName;

          if (next && nextVowel) {
            const vowel = schema[nextVowel] || "";
            return syllable.text.replace(new RegExp("\u{05B0}", "u"), vowel);
          }

          return syllable.text;
        }
      }
    ]
  }));```

The output is: 
`
C:\Developer\node_test>ts-node index.ts
Start
bǝrēʾšît wayyabdēl
bfunction (syllable, _hebrew, schema) {
                const next = syllable.next;
                // ensure type safety
                const nextVowel = next.vowelName === "SHEVA" ? "VOCAL_SHEVA" : next.vowelName;
                if (next && nextVowel) {
                    const vowel = schema[nextVowel] || "";
                    return syllable.text.replace(new RegExp("\u{05B0}", "u"), vowel);
                }
                return syllable.text;
            }rēʾšît wayyabdēl
`
johnlockejrr commented 1 year ago

“SHEVA Diphthong”? There’s no such thing.

On Thu, 16 Mar 2023 at 01:27, Zalexei @.***> wrote:

I'm trying to change scheme to be able to produce IPA representation. Could you please recommend how to deal with SHEVA Diphthong: usually it should be represented as empty sound, but in some words like 'נְקֻדָּה' it should act as 'e'. Haven't found the way to differentiate cases - or it's very specific?

Also what is the best way to define j sound ('ג'ון') - as additional_feature?

— Reply to this email directly, view it on GitHub https://github.com/charlesLoder/hebrew-transliteration/issues/63, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD44GHVXDASRPUG7WQSMIVTW4JNALANCNFSM6AAAAAAV4Q6VPY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

charlesLoder commented 1 year ago

@Zalexei could you define what you mean by "SHEVA Diphthong"? Your examples seem to indicate a vocal sheva (also called 'sheva na'), which is the VOCAL_SHEVA property.


Also what is the best way to define j sound ('ג'ון') - as additional_feature?

Yes, the spelling conventions in modern Hebrew for 'j' and 'ch' aren't defined in the schema (this package is more focused on Biblical Hebrew), so an ADDITIONAL_FEATURE would have to be used

charlesLoder commented 1 year ago

Stale