Class NGramGenerator

Namespace
NOpenNLP.Tools.Ngram
Assembly
NOpenNLP.Tools.dll

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

input char[]

the array of chars to convert to nGram

n int

The number of grams (chars) that each output gram will consist of

separator string

each char in each gram will be separated by this value if desired. Pass in empty string if no separator is desired

Returns

IList<string>

the generated ngrams

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

input IList<string>

the input tokens the output ngrams will be derived from

n int

the number of tokens as the sliding window

separator string

each string in each gram will be separated by this value if desired. Pass in empty string if no separator is desired

Returns

IList<string>

the generated ngrams