The process of building an N-Gram predictor is divided into five big steps, as follows:
- Create the general class within a file that has the same name:
using System.Collections; using System.Collections.Generic; using System.Text; public class NGramPredictor<T> { private int nValue; private Dictionary<string, KeyDataRecord<T>> data; }
- Implement the constructor for initializing the member variables:
public NGramPredictor(int windowSize) { nValue = windowSize + 1; data = new Dictionary<string, KeyDataRecord<T>>(); }
- Implement a static function for converting a set of actions into a string key:
public static string ArrToStrKey(ref T[] actions) { StringBuilder builder = new StringBuilder(); foreach (T a in actions) { builder.Append(a.ToString()); ...