src/utilities.js
/**
 * Count syllables and polysillabic words in a Natural Language Concrete Syntax Tree
 * @param {object} TextNodes Array of text nodes
 * @param {object} Hypher Hypher instance
 * @param {object} patterns Hyphenations patterns
 * @returns {{syllables:Number, polysillabicWords:Number}}
 */
Count syllables and polysillabic words in a Natural Language Concrete Syntax Tree
@param {object} TextNodes Array of text nodes
@param {object} Hypher Hypher instance
@param {object} patterns Hyphenations patterns
@returns {{syllables:Number, polysillabicWords:Number}}
Count syllables and polysillabic words in a Natural Language Concrete Syntax Tree @param { object } TextNodes Array of text nodes @param { object } Hypher Hypher instance @param { object } patterns Hyphenations patterns @returns {{ syllables : Number polysillabicWords : Number }}
function countSyllables(TextNodes, Hypher, patterns) {
  if (typeof TextNodes != "object" || Object.keys(TextNodes).length < 1) {
    throw new TypeError("Parameter 'TextNodes' must be a non-empty object");
  }
  try {
    const hypher = new Hypher(patterns);
    var syllables = 0;
    var polysillabicWords = [];
    for (let i = 0; i < TextNodes.length; i++) {
      if (TextNodes[i].value.length >= 3) {
        const hyphens = hypher.hyphenate(TextNodes[i].value);
        if (hyphens.length >= 3) {
          polysillabicWords.push(TextNodes[i].value);
        }
        syllables += hyphens.length;
      }
    }
  } catch (error) {
    throw new Error(error);
  }
  return { syllables: syllables, polysillabicWords: polysillabicWords.length };
}
function countSyllables ( TextNodes , Hypher , patterns ) { if ( typeof TextNodes != "object" || Object . keys ( TextNodes ) . length < 1 ) { throw new TypeError ( "Parameter 'TextNodes' must be a non-empty object" ) ; } try { const hypher = new Hypher ( patterns ) ; var syllables = 0 ; var polysillabicWords = [ ] ; for ( let i = 0 ; i < TextNodes . length ; i ++ ) { if ( TextNodes [ i ] . value . length >= 3 ) { const hyphens = hypher . hyphenate ( TextNodes [ i ] . value ) ; if ( hyphens . length >= 3 ) { polysillabicWords . push ( TextNodes [ i ] . value ) ; } syllables += hyphens . length ; } } } catch ( error ) { throw new Error ( error ) ; } return { syllables : syllables , polysillabicWords : polysillabicWords . length } ; }
Count syllables and polysillabic words in a Natural Language Concrete Syntax Tree
 @param {object} TextNodes Array of text nodes
 @param {object} Hypher Hypher instance
 @param {object} patterns Hyphenations patterns
 @returns {{syllables:Number, polysillabicWords:Number}}
Count syllables and polysillabic words in a Natural Language Concrete Syntax Tree @param { object } TextNodes Array of text nodes @param { object } Hypher Hypher instance @param { object } patterns Hyphenations patterns @returns {{ syllables : Number polysillabicWords : Number }}