# ReaderDelegateTokenCounter

Connects an application-owned tokenizer to Reader without adding a tokenizer package to its runtime graph.

Class 

`OfficeIMO.Reader`

**Namespace**

`OfficeIMO.Reader`

**Assembly**

`OfficeIMO.Reader.Core`

**Source revision**

`013c05ace7bb` with working tree changes

**Source**

[ReaderDelegateTokenCounter.cs:17](https://github.com/EvotecIT/OfficeIMO/blob/013c05ace7bb14e293639941ec9cf54eb5177a90/OfficeIMO.Reader.Core/ReaderDelegateTokenCounter.cs#L17)

**Implements**

`IReaderRangeTokenCounter` `IReaderTokenCounter`

**Modifiers**

sealed

Connects an application-owned tokenizer to Reader without adding a tokenizer package to its runtime graph.

## Inheritance

- object
- ReaderDelegateTokenCounter

## Remarks

Delegates must be deterministic, thread-safe and return non-negative counts. Include the tokenizer model or vocabulary version in the identifier so chunking evidence identifies the actual counting contract.

## Guides & Samples

Authored walkthroughs and practical samples linked to this API.

- [Chunk Documents for Search and AI](/docs/reader/chunking/) Guide
  
  Split documents into bounded, citable chunks with heading paths and page locations for search indexes and retrieval with OfficeIMO.Reader.

Filter members 

Show inherited

## Constructors

`public ReaderDelegateTokenCounter(string id, Func<string, int> count, Func<string, string, int, int, int>? countRange = null)` [#](#constructor-ctor-string-func-system-string-system-int32-func-system-string-system-string-system-int32-system-int32-system-int32)

[ReaderDelegateTokenCounter.cs:17](https://github.com/EvotecIT/OfficeIMO/blob/013c05ace7bb14e293639941ec9cf54eb5177a90/OfficeIMO.Reader.Core/ReaderDelegateTokenCounter.cs#L17)

Creates a tokenizer bridge with an optional allocation-free range callback.

Parameters

**id string required**

**count System.Func<string, int> required**

**countRange System.Func<string, string, int, int, int>? = null optional**

## Methods

CountTokens 2 overloads

`public int CountTokens(string text)` [#](#method-counttokens-string)

[ReaderDelegateTokenCounter.cs:25](https://github.com/EvotecIT/OfficeIMO/blob/013c05ace7bb14e293639941ec9cf54eb5177a90/OfficeIMO.Reader.Core/ReaderDelegateTokenCounter.cs#L25)

Counts tokens in the supplied text.

Parameters

**text string required**

Returns

`int`

`public int CountTokens(string prefix, string source, int start, int length)` [#](#method-counttokens-string-string-int32-int32)

[ReaderDelegateTokenCounter.cs:28](https://github.com/EvotecIT/OfficeIMO/blob/013c05ace7bb14e293639941ec9cf54eb5177a90/OfficeIMO.Reader.Core/ReaderDelegateTokenCounter.cs#L28)

Counts the exact concatenated output projection represented by a prefix and source range.

Parameters

**prefix string required**

**source string required**

**start int required**

**length int required**

Returns

`int`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public string Id { get; }` [#](#property-id)

[ReaderDelegateTokenCounter.cs:23](https://github.com/EvotecIT/OfficeIMO/blob/013c05ace7bb14e293639941ec9cf54eb5177a90/OfficeIMO.Reader.Core/ReaderDelegateTokenCounter.cs#L23)

Stable counter identifier retained in chunking evidence.

<!-- PowerForge markdown artifact sha256:877CFA278CA01E3A5C7F879DCA7848D5327319751417CD46061B4B66A7BD29A3 -->
