Created
February 23, 2024 13:38
-
-
Save bjoerntx/c3fb6bb7f3675b229577879508f00108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// split a text into chunks | |
private static List<string> CreateChunks(string text, int chunkSize, int overlap) | |
{ | |
List<string> chunks = new List<string>(); | |
// split the text into chunks | |
while (text.Length > chunkSize) | |
{ | |
chunks.Add(text.Substring(0, chunkSize)); | |
text = text.Substring(chunkSize - overlap); | |
} | |
// add the last chunk | |
chunks.Add(text); | |
return chunks; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment