Class POSTaggerME

Namespace
NOpenNLP.Tools.Postag
Assembly
NOpenNLP.Tools.dll

A part-of-speech tagger that uses maximum entropy. Tries to predict whether words are nouns, verbs, or any of 70 other POS tags depending on their surrounding context.

public class POSTaggerME : IPOSTagger
Inheritance
POSTaggerME
Implements
Inherited Members

Constructors

POSTaggerME(POSModel)

Initializes the current instance with the provided model.

public POSTaggerME(POSModel model)

Parameters

model POSModel

Fields

DEFAULT_BEAM_SIZE

public const int DEFAULT_BEAM_SIZE = 3

Field Value

int

contextGen

The feature context generator.

protected readonly IPOSContextGenerator contextGen

Field Value

IPOSContextGenerator

ngramDictionary

protected Dictionary? ngramDictionary

Field Value

Dictionary

size

The size of the beam to be used in determining the best sequence of pos tags.

protected readonly int size

Field Value

int

tagDictionary

Tag dictionary used for restricting words to a fixed set of tags.

protected ITagDictionary tagDictionary

Field Value

ITagDictionary

useClosedClassTagsFilter

Says whether a filter should be used to check whether a tag assignment is to a word outside of a closed class.

protected bool useClosedClassTagsFilter

Field Value

bool

Properties

AllPosTags

Retrieves an array of all possible part-of-speech tags from the tagger.

public virtual string[] AllPosTags { get; }

Property Value

string[]

String[]

Methods

BuildNGramDictionary(IObjectStream<POSSample?>, int)

public static Dictionary BuildNGramDictionary(IObjectStream<POSSample?> samples, int cutoff)

Parameters

samples IObjectStream<POSSample>
cutoff int

Returns

Dictionary

Exceptions

IOException

if reading from the IObjectStream<T> fails.

GetOrderedTags(IList<string>, IList<string>, int)

public virtual string[] GetOrderedTags(IList<string> words, IList<string> tags, int index)

Parameters

words IList<string>
tags IList<string>
index int

Returns

string[]

GetOrderedTags(IList<string>, IList<string>, int, double[]?)

public virtual string[] GetOrderedTags(IList<string> words, IList<string> tags, int index, double[]? tprobs)

Parameters

words IList<string>
tags IList<string>
index int
tprobs double[]

Returns

string[]

PopulatePOSDictionary(IObjectStream<POSSample?>, IMutableTagDictionary, int)

public static void PopulatePOSDictionary(IObjectStream<POSSample?> samples, IMutableTagDictionary dict, int cutoff)

Parameters

samples IObjectStream<POSSample>
dict IMutableTagDictionary
cutoff int

Exceptions

IOException

if reading from the IObjectStream<T> fails.

Probs()

Returns an array with the probabilities for each tag of the last tagged sentence.

public virtual double[] Probs()

Returns

double[]

an array with the probabilities for each tag of the last tagged sentence.

Probs(double[])

Populates the specified array with the probabilities for each tag of the last tagged sentence.

public virtual void Probs(double[] probs)

Parameters

probs double[]

An array to put the probabilities into.

Tag(int, string[])

Returns at most the specified number of taggings for the specified sentence.

public virtual string[][] Tag(int numTaggings, string[] sentence)

Parameters

numTaggings int

The number of tagging to be returned.

sentence string[]

An array of tokens which make up a sentence.

Returns

string[][]

At most the specified number of taggings for the specified sentence.

Tag(string[])

Assigns the sentence of tokens pos tags.

public virtual string[] Tag(string[] sentence)

Parameters

sentence string[]

The sentece of tokens to be tagged.

Returns

string[]

an array of pos tags for each token provided in sentence.

Tag(string[], object[]?)

public virtual string[] Tag(string[] sentence, object[]? additionalContext)

Parameters

sentence string[]
additionalContext object[]

Returns

string[]

TopKSequences(string[])

public virtual Sequence[] TopKSequences(string[] sentence)

Parameters

sentence string[]

Returns

Sequence[]

TopKSequences(string[], object[]?)

public virtual Sequence[] TopKSequences(string[] sentence, object[]? additionaContext)

Parameters

sentence string[]
additionaContext object[]

Returns

Sequence[]

Train(string, IObjectStream<POSSample?>, TrainingParameters, POSTaggerFactory)

Trains a POSModel.

public static POSModel Train(string languageCode, IObjectStream<POSSample?> samples, TrainingParameters trainParams, POSTaggerFactory posFactory)

Parameters

languageCode string

the language of the training data

samples IObjectStream<POSSample>

the samples used for the training

trainParams TrainingParameters

the machine learning train parameters

posFactory POSTaggerFactory

a POSTaggerFactory to get resources from

Returns

POSModel

the trained POSModel

Exceptions

IOException

if reading from the IObjectStream<T> fails.