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; }
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; }
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); }
public void Load(BinaryReader Input) { this.NotFreqCoder = SymbolCoderGenericIO.Load(Input); this.Dic = ListIGenericIO.Load(Input); }
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; }; }