estimateEmotionalIntensity method

double estimateEmotionalIntensity(
  1. String input
)

Estimates emotional intensity from the input text.

Implementation

double estimateEmotionalIntensity(String input) {
  final exclamationCount = '!'.allMatches(input).length;
  final capsRatio =
      input.runes.where((r) => r >= 65 && r <= 90).length /
          math.max(1, input.length);
  final intensifiers =
      RegExp(r'\b(very|extremely|super|really|absolutely|totally)\b')
          .allMatches(input.toLowerCase())
          .length;

  final score = (exclamationCount * 0.3 +
          capsRatio * 0.3 +
          intensifiers * 0.2)
      .clamp(0.0, 1.0);
  return score;
}