Search in sources :

Example 1 with IntSequenceOutputs

use of org.apache.lucene.util.fst.IntSequenceOutputs in project lucene-solr by apache.

the class Dictionary method affixFST.

private FST<IntsRef> affixFST(TreeMap<String, List<Integer>> affixes) throws IOException {
    IntSequenceOutputs outputs = IntSequenceOutputs.getSingleton();
    Builder<IntsRef> builder = new Builder<>(FST.INPUT_TYPE.BYTE4, outputs);
    IntsRefBuilder scratch = new IntsRefBuilder();
    for (Map.Entry<String, List<Integer>> entry : affixes.entrySet()) {
        Util.toUTF32(entry.getKey(), scratch);
        List<Integer> entries = entry.getValue();
        IntsRef output = new IntsRef(entries.size());
        for (Integer c : entries) {
            output.ints[output.length++] = c;
        }
        builder.add(scratch.get(), output);
    }
    return builder.finish();
}
Also used : Builder(org.apache.lucene.util.fst.Builder) BytesRefBuilder(org.apache.lucene.util.BytesRefBuilder) IntsRefBuilder(org.apache.lucene.util.IntsRefBuilder) IntSequenceOutputs(org.apache.lucene.util.fst.IntSequenceOutputs) List(java.util.List) ArrayList(java.util.ArrayList) IntsRef(org.apache.lucene.util.IntsRef) IntsRefBuilder(org.apache.lucene.util.IntsRefBuilder) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 BytesRefBuilder (org.apache.lucene.util.BytesRefBuilder)1 IntsRef (org.apache.lucene.util.IntsRef)1 IntsRefBuilder (org.apache.lucene.util.IntsRefBuilder)1 Builder (org.apache.lucene.util.fst.Builder)1 IntSequenceOutputs (org.apache.lucene.util.fst.IntSequenceOutputs)1