feat: bundle documents in index optionally

This commit is contained in:
Menci
2026-01-06 22:33:54 +08:00
parent 631f8ed771
commit 1a08454351
8 changed files with 112 additions and 11 deletions
@@ -33,9 +33,10 @@ public class LoadedInvertedIndex
public class InvertedIndexLoader
{
public static LoadedInvertedIndex Load(CompressedInvertedIndex compressed)
public static LoadedInvertedIndex Load(CompressedInvertedIndex compressed, string[]? documents = null)
{
var documents = compressed.documents;
documents ??= compressed.documents;
if (documents == null) throw new ArgumentException("Loading an inverted index without documents bundled requires documents to be provided explicitly.");
var documentCodePoints = documents.Select(document => document.ToCodePoints().ToArray()).ToArray();
var romajiTrie = TrieDeserializer.Deserialize(compressed.tries.romaji);