Inheritance: ISymbolCoder
示例#1
0
 public static SequenceBuilder GetWTM_TopKFreqCoder(byte bits_per_code, int K, SequenceBuilder seq_builder = null)
 {
     return delegate (IList<int> seq, int sigma) {
         var wt = new WTM();
         TopKFreqCoder symcoder;
         var __coder = new EqualSizeCoder(bits_per_code, sigma - 1);
         var freqs = new int[sigma];
         for (int i = 0; i < seq.Count; ++i) {
             freqs[seq[i]]++;
         }
         symcoder = new TopKFreqCoder(K, freqs, __coder);
         wt.Build(seq, sigma, symcoder, seq_builder);
         return wt;
     };
 }
示例#2
0
文件: WTM.cs 项目: sadit/natix
 public void Build(IList<int> text, int alphabet_size, ISymbolCoder symbol_split = null, SequenceBuilder seq_builder = null)
 {
     if (symbol_split == null) {
         symbol_split = new EqualSizeCoder(4, alphabet_size-1);
     }
     this.SymbolCoder = symbol_split;
     var list = this.SymbolCoder.Encode(0, null);
     var numbits = list[0].numbits;
     var arity = (short)(1 << numbits);
     this.Alphabet = new WTM_Leaf[alphabet_size];
     this.Root = new WTM_Inner (arity, null, true);
     for (int i = 0; i < text.Count; i++) {
         this.Add (text [i], list);
     }
     if (seq_builder == null) {
         seq_builder = SequenceBuilders.GetSeqPlain(arity);
     }
     this.FinishBuild (this.Root, seq_builder, arity);
 }
示例#3
0
 public static SequenceBuilder GetWTM(byte bits_per_code, SequenceBuilder seq_builder = null)
 {
     return delegate (IList<int> seq, int sigma) {
         var wt = new WTM();
         var symcoder = new EqualSizeCoder(bits_per_code, sigma - 1);
         wt.Build(seq, sigma, symcoder, seq_builder);
         return wt;
     };
 }