Zum Hauptinhalt springen

Class: SentenceWindowNodeParser

A NodeParser generates Nodes from Documents

Implements

Constructors

constructor

new SentenceWindowNodeParser(init?)

Parameters

NameType
init?Partial<SentenceWindowNodeParser>

Defined in

packages/core/src/nodeParsers/SentenceWindowNodeParser.ts:36

Properties

includeMetadata

includeMetadata: boolean = true

Whether to include metadata in the nodes.

Defined in

packages/core/src/nodeParsers/SentenceWindowNodeParser.ts:30


includePrevNextRel

includePrevNextRel: boolean = true

Whether to include previous and next relationships in the nodes.

Defined in

packages/core/src/nodeParsers/SentenceWindowNodeParser.ts:34


originalTextMetadataKey

originalTextMetadataKey: string = DEFAULT_OG_TEXT_METADATA_KEY

The metadata key to store the original sentence in.

Defined in

packages/core/src/nodeParsers/SentenceWindowNodeParser.ts:26


textSplitter

textSplitter: SentenceSplitter

The text splitter to use.

Defined in

packages/core/src/nodeParsers/SentenceWindowNodeParser.ts:14


windowMetadataKey

windowMetadataKey: string = DEFAULT_WINDOW_METADATA_KEY

The metadata key to store the sentence window under.

Defined in

packages/core/src/nodeParsers/SentenceWindowNodeParser.ts:22


windowSize

windowSize: number = DEFAULT_WINDOW_SIZE

The number of sentences on each side of a sentence to capture.

Defined in

packages/core/src/nodeParsers/SentenceWindowNodeParser.ts:18

Methods

buildWindowNodesFromDocument

Protected buildWindowNodesFromDocument(doc): BaseNode<Metadata>[]

Parameters

NameType
docBaseNode<Metadata>

Returns

BaseNode<Metadata>[]

Defined in

packages/core/src/nodeParsers/SentenceWindowNodeParser.ts:53


getNodesFromDocuments

getNodesFromDocuments(documents): BaseNode<Metadata>[]

Generates an array of nodes from an array of documents.

Parameters

NameTypeDescription
documentsBaseNode<Metadata>[]The documents to generate nodes from.

Returns

BaseNode<Metadata>[]

An array of nodes.

Implementation of

NodeParser.getNodesFromDocuments

Defined in

packages/core/src/nodeParsers/SentenceWindowNodeParser.ts:47


fromDefaults

Static fromDefaults(init?): SentenceWindowNodeParser

Parameters

NameType
init?Partial<SentenceWindowNodeParser>

Returns

SentenceWindowNodeParser

Defined in

packages/core/src/nodeParsers/SentenceWindowNodeParser.ts:41