Class NGramGenerator
Generates an nGram, with optional separator, and returns the grams as a list of strings.
public static class NGramGenerator
- Inheritance
-
NGramGenerator
- Inherited Members
Methods
Generate(char[], int, string)
Generates an nGram based on a char[] input.
public static IList<string> Generate(char[] input, int n, string separator)
Parameters
inputchar[]the array of chars to convert to nGram
nintThe number of grams (chars) that each output gram will consist of
separatorstringeach char in each gram will be separated by this value if desired. Pass in empty string if no separator is desired
Returns
Generate(IList<string>, int, string)
Creates an ngram separated by the separator param value i.e. a,b,c,d with n = 3 and separator = "-" would return a-b-c,b-c-d
public static IList<string> Generate(IList<string> input, int n, string separator)
Parameters
inputIList<string>the input tokens the output ngrams will be derived from
nintthe number of tokens as the sliding window
separatorstringeach string in each gram will be separated by this value if desired. Pass in empty string if no separator is desired