Giter VIP home page Giter VIP logo

Comments (1)

charlesLoder avatar charlesLoder commented on June 21, 2024 1

@inklesspen

Thanks for this question!

I can think of two ways to get the results you need.

Postprocessing

Because the goal is to separate the Latin vowel characters, it may be best to process the transliterated text:

const transliteration = transliterate("אֵל חַי וְקַיָּם תָּמִיד יִמְלֹךְ עָלֵינוּ לְעוֹלָם וָעֶד׃", { customSchema });
// El ḥay vekayam tamid yimloḥ aleynu leolam vaed.

transliteration.split(" ").map(w => {
  const twoAdjacentVowels = /([aeiou])([aeiou])/g;
  return w.replaceAll(twoAdjacentVowels, "$1'$2");
}).join(" ");

// "El ḥay vekayam tamid yimloḥ aleynu le'olam va'ed."

Additional feature

An additional feature can be used with a callback like this:

const str = `אֵל חַי וְקַיָּם תָּמִיד יִמְלֹךְ עָלֵינוּ לְעוֹלָם וָעֶד׃`;

transliterate(str, {
  ...customSchema
  ADDITIONAL_FEATURES: [
    // if you customize your customSchema like I did here
    // don't forget the features you already have, or they will get overwritten
    {
      HEBREW: /[עא]/,
      FEATURE: "cluster",
      TRANSLITERATION: (cluster, _, schema) => {
        const syllable = cluster.syllable;
        const onset = syllable.onset;
        const clusterText = cluster.text;

        // this would mean that the alef or ayin do not contain a vowel
        if (onset != "ע" && onset != "א") {
          return clusterText;
        }

        // this would mean that there is no vowel preceding the alef or ayin, thus no need to add an apostrophe
        const prevSyllable = syllable.prev?.value;
        if (!prevSyllable) {
          return clusterText;
        }

        const key = onset === "ע" ? "AYIN" : "ALEF";

        return clusterText.replace(onset, "'" + schema[key]);
      }
    }
  ]
});

// el ḥay vekayam tamid yimloḥ alenu le'olam va'ed

The first is less integrated with the rules of the transliteration, but is probably easier to reason about. With the second, I imagine there are quite a few edge cases that could produce incorrect results.

I hope that helps!

from hebrew-transliteration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.