Class NGramCharModel
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
ngramstring
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
Contains(string)
Checks if the given tokens are contained by the current instance.
public virtual bool Contains(string ngram)
Parameters
ngramstring
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
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetCount(string)
Retrieves the count of the given ngram.
public virtual int GetCount(string ngram)
Parameters
ngramstringan 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
ngramstring
SetCount(string, int)
Sets the count of an existing ngram.
public virtual void SetCount(string ngram, int count)
Parameters
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.