참고소스 수정본
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
from neo4j_graphrag.experimental.components.text_splitters.base import TextSplitter
|
||||
from neo4j_graphrag.experimental.components.types import TextChunk, TextChunks
|
||||
|
||||
|
||||
class MySplitter(TextSplitter):
|
||||
async def run(self, text: str) -> TextChunks:
|
||||
# your logic here
|
||||
return TextChunks(
|
||||
chunks=[
|
||||
TextChunk(text="", index=0),
|
||||
# optional metadata
|
||||
TextChunk(text="", index=1, metadata={"key": "value"}),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
from neo4j_graphrag.experimental.components.text_splitters.fixed_size_splitter import (
|
||||
FixedSizeSplitter,
|
||||
)
|
||||
from neo4j_graphrag.experimental.components.types import TextChunks
|
||||
|
||||
|
||||
async def main() -> TextChunks:
|
||||
splitter = FixedSizeSplitter(
|
||||
# optionally, configure chunk_size, chunk_overlap, and approximate flag
|
||||
# chunk_size=4000,
|
||||
# chunk_overlap=200,
|
||||
# approximate = False
|
||||
)
|
||||
chunks = await splitter.run(text="text to split")
|
||||
return chunks
|
||||
Reference in New Issue
Block a user