public NormalizeCharMap build() {final FST<CharsRef> map;try {final Outputs<CharsRef> outputs = CharSequenceOutputs.getSingleton();final FSTCompiler<CharsRef> fstCompiler = new FSTCompiler<>(FST.INPUT_TYPE.BYTE2, outputs);final IntsRefBuilder scratch = new IntsRefBuilder();for(Map.Entry<String,String> ent : pendingPairs.entrySet()) {fstCompiler.add(Util.toUTF16(ent.getKey(), scratch),new CharsRef(ent.getValue()));}map = fstCompiler.compile();pendingPairs.clear();} catch (IOException ioe) {throw new RuntimeException(ioe);}return new NormalizeCharMap(map);}
public virtual NormalizeCharMap Build(){FST<CharsRef> map;try{Outputs<CharsRef> outputs = CharSequenceOutputs.Singleton;Builder<CharsRef> builder = new Builder<CharsRef>(FST.INPUT_TYPE.BYTE2, outputs);Int32sRef scratch = new Int32sRef();foreach (var ent in pendingPairs){builder.Add(Lucene.Net.Util.Fst.Util.ToUTF16(ent.Key, scratch), new CharsRef(ent.Value));}map = builder.Finish();pendingPairs.Clear();}catch (IOException ioe){throw new Exception("Should never happen", ioe);}return new NormalizeCharMap(map);}