Method ImportTextAsync
ImportTextAsync(string, TextChunking, string, string, CancellationToken)
Asynchronously imports text data into a specified DataSource object, creating or updating a Section entry.
public Task<DataSource> ImportTextAsync(string data, TextChunking textChunking, string dataSourceIdentifier, string sectionIdentifier = "default", CancellationToken cancellationToken = default)
Parameters
data
stringThe textual data to be imported.
textChunking
TextChunkingA TextChunking object specifying how text is chunked.
dataSourceIdentifier
stringThe unique identifier for the DataSource. If it matches an existing DataSource, the data is added as a new section. Otherwise, a new DataSource is created.
sectionIdentifier
stringOptional. The new Section's identifier. Defaults to 'default'.
cancellationToken
CancellationTokenOptional. A CancellationToken to cancel the operation.
Returns
- Task<DataSource>
A task that represents the asynchronous operation. The task result contains the DataSource object into which the data has been imported.
Exceptions
- ArgumentNullException
Thrown if
data
ordataSourceIdentifier
is null or empty.- OperationCanceledException
Thrown if the operation is canceled.
ImportTextAsync(IList<string>, TextChunking, string, IList<string>, CancellationToken)
Asynchronously imports an array of text data into a specified DataSource object, dynamically creating new Section entries for each item.
public Task<DataSource> ImportTextAsync(IList<string> data, TextChunking textChunking, string dataSourceIdentifier, IList<string> sectionIdentifiers, CancellationToken cancellationToken = default)
Parameters
data
IList<string>An array of text strings to be imported. Each string can represent a "page" of data.
textChunking
TextChunkingA TextChunking object specifying how text is chunked.
dataSourceIdentifier
stringA unique identifier for the DataSource. If it matches an existing DataSource, new sections are added; otherwise, a new one is created.
sectionIdentifiers
IList<string>A list of identifiers for the new Sections. Its length must match the number of items in
data
.cancellationToken
CancellationTokenOptional. A CancellationToken for canceling the operation.
Returns
- Task<DataSource>
A task that represents the asynchronous operation. The task result contains the updated or newly created DataSource.
Exceptions
- ArgumentNullException
Thrown if
data
,dataSourceIdentifier
, orsectionIdentifiers
is null or empty.- ArgumentOutOfRangeException
Thrown if the number of
sectionIdentifiers
does not match the number of items indata
.