alexa
menu

Document Processing

    Show / Hide Table of Contents

    DefaultTokenCounter Class

    Provides the default implementation for estimating token counts.

    Inheritance
    System.Object
    DefaultTokenCounter
    Implements
    ITokenCounter
    Namespace: Syncfusion.DocumentChunking
    Assembly: Syncfusion.DocumentChunking.Base.dll
    Syntax
    public class DefaultTokenCounter : Object, ITokenCounter
    Remarks

    This implementation uses a heuristic algorithm to estimate token counts without requiring an external tokenizer. The returned value is an approximation and may differ from the token count produced by a specific language model or embedding model. For model-specific token counts, configure the chunking operation with an ITokenCounter implementation that uses the tokenizer associated with the target model.

    Constructors

    DefaultTokenCounter()

    Declaration
    public DefaultTokenCounter()

    Methods

    CountTokens(String)

    Estimates the number of tokens in the specified text.

    Declaration
    public int CountTokens(string text)
    Parameters
    Type Name Description
    System.String text

    The text for which to estimate the token count.

    Returns
    Type Description
    System.Int32

    The estimated number of tokens in text, or 0 when text is null, empty, or consists only of white-space characters.

    Implements

    ITokenCounter
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved