Class DocumentCategorizerME

Namespace
NOpenNLP.Tools.Doccat
Assembly
NOpenNLP.Tools.dll

Maxent implementation of IDocumentCategorizer.

public class DocumentCategorizerME : IDocumentCategorizer
Inheritance
DocumentCategorizerME
Implements
Inherited Members

Constructors

DocumentCategorizerME(DoccatModel)

Initializes the current instance with a doccat model. Default feature generation is used.

public DocumentCategorizerME(DoccatModel model)

Parameters

model DoccatModel

the doccat model

Properties

NumberOfCategories

Gets the number of categories

public virtual int NumberOfCategories { get; }

Property Value

int

Methods

Categorize(string[])

Categorizes the given text.

public virtual double[] Categorize(string[] text)

Parameters

text string[]

the text to categorize

Returns

double[]

Categorize(string[], IDictionary<string, object>)

Categorize the given text provided as tokens along with the provided extra information

public virtual double[] Categorize(string[] text, IDictionary<string, object> extraInformation)

Parameters

text string[]

text tokens to categorize

extraInformation IDictionary<string, object>

additional information

Returns

double[]

GetAllResults(double[])

Gets the name of the category associated with the given probabilities

public virtual string GetAllResults(double[] results)

Parameters

results double[]

the probabilities of each category

Returns

string

the name of the outcome

GetBestCategory(double[])

Gets the best category from previously generated outcome probabilities

public virtual string GetBestCategory(double[] outcome)

Parameters

outcome double[]

a vector of outcome probabilities

Returns

string

the best category string

GetCategory(int)

Gets the category at a given index

public virtual string GetCategory(int index)

Parameters

index int

the index

Returns

string

a category

GetIndex(string)

Gets the index of a certain category

public virtual int GetIndex(string category)

Parameters

category string

the category

Returns

int

an index

ScoreMap(string[])

Returns a map in which the key is the category name and the value is the score

public virtual IDictionary<string, double> ScoreMap(string[] text)

Parameters

text string[]

the input text to classify

Returns

IDictionary<string, double>

the score map

SortedScoreMap(string[])

Returns a map with the score as a key in ascending order. The value is a set of categories with the score. Many categories can have the same score, hence the set as value

public virtual SortedDictionary<double, ISet<string>> SortedScoreMap(string[] text)

Parameters

text string[]

the input text to classify

Returns

SortedDictionary<double, ISet<string>>

the sorted score map

Train(string, IObjectStream<DocumentSample?>, TrainingParameters, DoccatFactory)

public static DoccatModel Train(string languageCode, IObjectStream<DocumentSample?> samples, TrainingParameters mlParams, DoccatFactory factory)

Parameters

languageCode string
samples IObjectStream<DocumentSample>
mlParams TrainingParameters
factory DoccatFactory

Returns

DoccatModel