Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67411

how to count the number of words in hindi

$
0
0

I have a javascript file and I would like to know how to count the number of hindi words in my textarea using javascript. it counts the number of english words fine but not with hindi words. Can someone help me please?

javascript code:

function getDifficultSentences(p) {
    let sentences = getSentenceFromParagraph(p);
    data.sentences += sentences.length;
    let hardOrNot = sentences.map(sent => {
      let cleanSentence = sent.replace(/[^a-z|]/gi, "") + "|";
      let words = cleanSentence.split("").length;  // the line where the I used for counting the words
      document.getElementById("nice").innerHTML= words.toString();
      let letters = cleanSentence.split("").join("").length;
      data.words += words;
      sent = getAdverbs(sent);
      sent = getComplex(sent);
      sent = getPassive(sent);
      sent = getQualifier(sent);
      sent = countWords(sent);
      //sent = getComplexDigit(sent);
      let level = calculateLevel(letters, words, 1);
      if (words < 14) {
        return sent;
      } else if (words >= 14 && words< 25) {
        data.hardSentences += 1;
        return `<span class="hardSentence">${sent}</span>`;
      } else if (words >= 30) {
        data.veryHardSentences += 1;
        return `<span class="veryHardSentence">${sent}</span>`;
      } else {
        return sent;
      }
    });

    return hardOrNot.join("");
  }

Viewing all articles
Browse latest Browse all 67411

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>