alexa
menu

Document Processing

    Show / Hide Table of Contents

    ChunkingService Class

    Provides operations for generating chunks suitable for retrieval-augmented generation (RAG) from documents.

    Inheritance
    System.Object
    ChunkingService
    Implements
    IChunkingService
    Namespace: Syncfusion.DocumentChunking
    Assembly: Syncfusion.DocumentChunking.Base.dll
    Syntax
    public sealed class ChunkingService : Object, IChunkingService

    Constructors

    ChunkingService()

    Initializes a new instance of the ChunkingService class using a DefaultTokenCounter.

    Declaration
    public ChunkingService()

    Methods

    Chunk(Stream, String, ChunkingOptions)

    Generates chunks from the document contained in the specified stream.

    Declaration
    public IChunkingResult Chunk(Stream stream, string sourceName, ChunkingOptions options = null)
    Parameters
    Type Name Description
    System.IO.Stream stream

    The stream containing the document data.

    System.String sourceName

    The source name, including the file extension used for document format detection and metadata generation.

    ChunkingOptions options

    The chunking options to use, or null to use the default options.

    Returns
    Type Description
    IChunkingResult

    The result of the chunking operation.

    Exceptions
    Type Condition
    System.ArgumentNullException

    stream or sourceName is null.

    System.ArgumentException

    sourceName is empty or consists only of white-space characters.

    System.InvalidOperationException

    The document format is not supported.

    Chunk(String, ChunkingOptions)

    Generates chunks from the document at the specified file path.

    Declaration
    public IChunkingResult Chunk(string filePath, ChunkingOptions options = null)
    Parameters
    Type Name Description
    System.String filePath

    The absolute or relative path of the document to process.

    ChunkingOptions options

    The chunking options to use, or null to use the default options.

    Returns
    Type Description
    IChunkingResult

    The result of the chunking operation.

    Exceptions
    Type Condition
    System.ArgumentNullException

    filePath is null.

    System.ArgumentException

    filePath is empty or consists only of white-space characters.

    System.IO.FileNotFoundException

    The specified file does not exist.

    System.InvalidOperationException

    The document format is not supported.

    ChunkAsync(Stream, String, ChunkingOptions, CancellationToken)

    Asynchronously generates chunks from the document contained in the specified stream.

    Declaration
    public Task<IChunkingResult> ChunkAsync(Stream stream, string sourceName, ChunkingOptions options = null, CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    System.IO.Stream stream

    The stream containing the document data.

    System.String sourceName

    The source name, including the file extension used for document format detection and metadata generation.

    ChunkingOptions options

    The chunking options to use, or null to use the default options.

    System.Threading.CancellationToken cancellationToken

    The token used to cancel the operation.

    Returns
    Type Description
    System.Threading.Tasks.Task<IChunkingResult>

    A task that represents the asynchronous operation. The task result contains the result of the chunking operation.

    Exceptions
    Type Condition
    System.ArgumentNullException

    stream is null.

    System.ArgumentException

    sourceName is null, empty, or consists only of white-space characters.

    System.InvalidOperationException

    The document format is not supported.

    System.OperationCanceledException

    The operation is canceled by cancellationToken.

    ChunkAsync(String, ChunkingOptions, CancellationToken)

    Asynchronously generates chunks from the document at the specified file path.

    Declaration
    public Task<IChunkingResult> ChunkAsync(string filePath, ChunkingOptions options = null, CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    System.String filePath

    The absolute or relative path of the document to process.

    ChunkingOptions options

    The chunking options to use, or null to use the default options.

    System.Threading.CancellationToken cancellationToken

    The token used to cancel the operation.

    Returns
    Type Description
    System.Threading.Tasks.Task<IChunkingResult>

    A task that represents the asynchronous operation. The task result contains the result of the chunking operation.

    Exceptions
    Type Condition
    System.ArgumentNullException

    filePath is null.

    System.ArgumentException

    filePath is empty or consists only of white-space characters.

    System.IO.FileNotFoundException

    The specified file does not exist.

    System.InvalidOperationException

    The document format is not supported.

    System.OperationCanceledException

    The operation is canceled by cancellationToken.

    Implements

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