48 public override async Task<List<(int, int)>>
Split(
string input)
50 List<(int, int)> indices =
new List<(
int,
int)>();
51 List<int> tokens = await search.Tokenize(input);
52 if (tokens.Count == 0)
return indices;
55 for (
int i = 0; i < tokens.Count; i +=
numTokens)
57 int batchTokens = Math.Min(tokens.Count, i +
numTokens) - i;
58 string detokenised = await search.Detokenize(tokens.GetRange(i, batchTokens));
59 int endIndex = DetermineEndIndex(input, detokenised, startIndex);
60 indices.Add((startIndex, endIndex));
61 startIndex = endIndex + 1;
62 if (endIndex == input.Length - 1)
break;
64 if (startIndex <= input.Length - 1) indices.Add((startIndex, input.Length - 1));