Lucene.Net.Analysis.CharFilters.NormalizeCharMap.Builder.Build C# (CSharp) Method

Build() public method

Builds the NormalizeCharMap; call this once you are done calling #add.
public Build ( ) : NormalizeCharMap
return NormalizeCharMap
            public virtual NormalizeCharMap Build()
            {

                FST<CharsRef> map;
                try
                {
                    Outputs<CharsRef> outputs = CharSequenceOutputs.Singleton;
                    Builder<CharsRef> builder = new Builder<CharsRef>(FST.INPUT_TYPE.BYTE2, outputs);
                    IntsRef scratch = new IntsRef();
                    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)
                {
                    // Bogus FST IOExceptions!!  (will never happen)
                    throw new Exception("Should never happen", ioe);
                }

                return new NormalizeCharMap(map);
            }
        }

Usage Example

 // TODO: this should use inputstreams from the loader, not File!
 public virtual void Inform(IResourceLoader loader)
 {
     if (mapping != null)
     {
         IList<string> wlist = null;
         if (File.Exists(mapping))
         {
             wlist = new List<string>(GetLines(loader, mapping));
         }
         else
         {
             var files = SplitFileNames(mapping);
             wlist = new List<string>();
             foreach (string file in files)
             {
                 var lines = GetLines(loader, file.Trim());
                 wlist.AddRange(lines);
             }
         }
         NormalizeCharMap.Builder builder = new NormalizeCharMap.Builder();
         ParseRules(wlist, builder);
         normMap = builder.Build();
         if (normMap.map == null)
         {
             // if the inner FST is null, it means it accepts nothing (e.g. the file is empty)
             // so just set the whole map to null
             normMap = null;
         }
     }
 }
All Usage Examples Of Lucene.Net.Analysis.CharFilters.NormalizeCharMap.Builder::Build
NormalizeCharMap.Builder