Creates a word tagger from a training set in an array of tokens and their labels.


init(trainingData: [(tokens: [MLWordTagger.Token], labels: [String])], parameters: MLWordTagger.ModelParameters = ModelParameters(validationData: [])) throws



The array of tuples containing the tokens and their labels.


The model parameters to use when creating the word tagger.


You use this initializer to create a word tagger when your training data are in arrays in memory. For example, start with an array of tokens and an array of labels, one for each token.

let tokenArray = [

let labelArray = [

Then create the word tagger by putting the arrays into a tuple.

let tupleArray = [(tokenArray, labelArray)]
let wordTagger = try MLWordTagger(trainingData: tupleArray)

See Also

Creating and Training a Word Tagger

typealias MLWordTagger.Token

The token type of a word tagger, which is String.

struct MLWordTagger.ModelParameters

Parameters that affect the process of training a model.

let modelParameters: MLWordTagger.ModelParameters

The configuration parameters that the word tagger used for training during initialization.