Class TokenEstimator

java.lang.Object
com.tnsai.reasoning.TokenEstimator

public final class TokenEstimator extends Object
Rough token count estimator for text content.

Uses the ~4 characters per token heuristic for English text. Suitable for budget estimation and context window management, not for precise billing calculations.

  • Method Details

    • estimate

      public static int estimate(String text)
      Estimates token count from text length.
      Parameters:
      text - the text to estimate
      Returns:
      estimated token count, 0 if text is null or empty