示例#1
0
 public TopKFreqCoder(int K, IList<int> alphabet_freqs, ISymbolCoder not_freq_coder)
 {
     var top = new TopK<int> (K);
     var n = alphabet_freqs.Count;
     this.Dic = new int[K];
     int i;
     for (i = 0; i < n; ++i) {
         top.Push (-alphabet_freqs [i], i);
     }
     i = 0;
     foreach (var p in top.Items.Traverse()) {
         this.Dic[i] = p.Value;
         ++i;
     }
     this.NotFreqCoder = not_freq_coder;
 }
示例#2
0
文件: WTM.cs 项目: sadit/natix
 public void Load(BinaryReader Input)
 {
     var size = Input.ReadInt32 ();
     this.SymbolCoder = SymbolCoderGenericIO.Load (Input);
     this.Alphabet = new WTM_Leaf[size];
     this.Root = this.LoadNode (Input, null) as WTM_Inner;
 }
示例#3
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);
 }
示例#4
0
 public void Load(BinaryReader Input)
 {
     this.NotFreqCoder = SymbolCoderGenericIO.Load(Input);
     this.Dic = ListIGenericIO.Load(Input);
 }
示例#5
0
 public static SequenceBuilder GetWTM( ISymbolCoder symcoder = null, SequenceBuilder seq_builder = null)
 {
     return delegate (IList<int> seq, int sigma) {
         var wt = new WTM();
         wt.Build(seq, sigma, symcoder, seq_builder);
         return wt;
     };
 }