Class POSTaggerME
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
modelPOSModel
Fields
DEFAULT_BEAM_SIZE
public const int DEFAULT_BEAM_SIZE = 3
Field Value
contextGen
The feature context generator.
protected readonly IPOSContextGenerator contextGen
Field Value
ngramDictionary
protected Dictionary? ngramDictionary
Field Value
size
The size of the beam to be used in determining the best sequence of pos tags.
protected readonly int size
Field Value
tagDictionary
Tag dictionary used for restricting words to a fixed set of tags.
protected ITagDictionary tagDictionary
Field Value
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
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
samplesIObjectStream<POSSample>cutoffint
Returns
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
Returns
- string[]
GetOrderedTags(IList<string>, IList<string>, int, double[]?)
public virtual string[] GetOrderedTags(IList<string> words, IList<string> tags, int index, double[]? tprobs)
Parameters
Returns
- string[]
PopulatePOSDictionary(IObjectStream<POSSample?>, IMutableTagDictionary, int)
public static void PopulatePOSDictionary(IObjectStream<POSSample?> samples, IMutableTagDictionary dict, int cutoff)
Parameters
samplesIObjectStream<POSSample>dictIMutableTagDictionarycutoffint
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
probsdouble[]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
numTaggingsintThe number of tagging to be returned.
sentencestring[]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
sentencestring[]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
Returns
- string[]
TopKSequences(string[])
public virtual Sequence[] TopKSequences(string[] sentence)
Parameters
sentencestring[]
Returns
- Sequence[]
TopKSequences(string[], object[]?)
public virtual Sequence[] TopKSequences(string[] sentence, object[]? additionaContext)
Parameters
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
languageCodestringthe language of the training data
samplesIObjectStream<POSSample>the samples used for the training
trainParamsTrainingParametersthe machine learning train parameters
posFactoryPOSTaggerFactorya POSTaggerFactory to get resources from
Returns
Exceptions
- IOException
if reading from the IObjectStream<T> fails.