Class NGramCharModel

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

The NGramCharModel can be used to create character ngrams.

public class NGramCharModel : IEnumerable<string>, IEnumerable
Inheritance
NGramCharModel
Implements
Inherited Members

Constructors

NGramCharModel()

Initializes an empty instance.

public NGramCharModel()

Properties

Count

Retrieves the number of string entries in the current instance.

public virtual int Count { get; }

Property Value

int

number of different grams

NumberOfGrams

Retrieves the total count of all Ngrams.

public virtual int NumberOfGrams { get; }

Property Value

int

total count of all ngrams

Methods

Add(string)

Adds one NGram, if it already exists the count increase by one.

public virtual void Add(string ngram)

Parameters

ngram string

Add(string, int, int)

Adds a char sequence that will be ngrammed into chars.

public virtual void Add(string chars, int minLength, int maxLength)

Parameters

chars string
minLength int
maxLength int

Contains(string)

Checks if the given tokens are contained by the current instance.

public virtual bool Contains(string ngram)

Parameters

ngram string

Returns

bool

true if the ngram is contained

Cutoff(int, int)

Deletes all ngram which do appear less than the cutoffUnder value and more often than the cutoffOver value.

public virtual void Cutoff(int cutoffUnder, int cutoffOver)

Parameters

cutoffUnder int
cutoffOver int

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetCount(string)

Retrieves the count of the given ngram.

public virtual int GetCount(string ngram)

Parameters

ngram string

an ngram

Returns

int

count of the ngram or 0 if it is not contained

GetEnumerator()

Retrieves an IEnumerator<T> over all string entries.

public IEnumerator<string> GetEnumerator()

Returns

IEnumerator<string>

iterator over all grams

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

Remove(string)

Removes the specified tokens form the NGram model, they are just dropped.

public virtual void Remove(string ngram)

Parameters

ngram string

SetCount(string, int)

Sets the count of an existing ngram.

public virtual void SetCount(string ngram, int count)

Parameters

ngram string
count int

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

See Also