Code we use - Preview

typescript
const rules = [
  {
    condition: sentences.length === 0,
    apply: () => {
      penalty += 1
    },
  },
  {
    condition: true,
    apply: () => {
      sentences.forEach((sentence) => {
        const wordCount = sentence.split(/\s+/).filter(Boolean).length

        if (wordCount > WORDS_LIMIT_PER_SENTENCE) {
          const excessWords = wordCount - WORDS_LIMIT_PER_SENTENCE
          penalty += Math.round(excessWords * 0.025 * 100) / 100

          exceededSentences.push(sentence)
        }
      })
    },
  },
]

To strike the right balance, aim for sentences containing between 10 and 25 words.