Package org.egothor.stemmer
Class FrequencyTrieBuilders
java.lang.Object
org.egothor.stemmer.FrequencyTrieBuilders
Factory utilities related to
FrequencyTrie.Builder.
This helper reconstructs writable builders from compiled read-only tries. The reconstruction preserves the semantics and local counts of the compiled trie as currently stored, which makes it suitable for subsequent modifications followed by recompilation.
Reconstruction operates on the compiled form. Therefore, if the compiled trie was produced using a reduction mode that merged semantically equivalent subtrees, the recreated builder reflects that reduced compiled state rather than the exact original unreduced insertion history.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> FrequencyTrie.Builder<V> copyOf(FrequencyTrie<V> source, IntFunction<V[]> arrayFactory, ReductionMode reductionMode) Reconstructs a new writable builder from a compiled read-only trie using default settings for the supplied reduction mode.static <V> FrequencyTrie.Builder<V> copyOf(FrequencyTrie<V> source, IntFunction<V[]> arrayFactory, ReductionSettings reductionSettings) Reconstructs a new writable builder from a compiled read-only trie.
-
Method Details
-
copyOf
public static <V> FrequencyTrie.Builder<V> copyOf(FrequencyTrie<V> source, IntFunction<V[]> arrayFactory, ReductionSettings reductionSettings) Reconstructs a new writable builder from a compiled read-only trie.The returned builder contains the same key-local value counts as the supplied compiled trie. Callers may continue modifying the returned builder and then compile a new
FrequencyTrieinstance.- Type Parameters:
V- value type- Parameters:
source- source compiled triearrayFactory- array factory for the reconstructed builderreductionSettings- reduction settings to associate with the new builder- Returns:
- reconstructed writable builder
- Throws:
NullPointerException- if any argument isnull
-
copyOf
public static <V> FrequencyTrie.Builder<V> copyOf(FrequencyTrie<V> source, IntFunction<V[]> arrayFactory, ReductionMode reductionMode) Reconstructs a new writable builder from a compiled read-only trie using default settings for the supplied reduction mode.- Type Parameters:
V- value type- Parameters:
source- source compiled triearrayFactory- array factory for the reconstructed builderreductionMode- reduction mode to associate with the new builder- Returns:
- reconstructed writable builder
- Throws:
NullPointerException- if any argument isnull
-