class

Cadmium::Classifier::Viterbi

Inherits Reference < Object

TODO : add Kneser-Ney smoothing This is a Hidden Markov Model classifier which uses the Viterbi algorithm. It is efficient in predicting a state given prior observations matched to states. In NLP, it is often used to attribut POS tags to words of a text. As such it is used by Cadmium::POSTagger.

Constructors

new(ngrams_size : Int32 = 3)
Source

Instance methods

classify(sequence_of_observations : Array(String)) : Hash(String, String)
Source
emission_matrix
Source
emission_matrix_to_a

Helper to get emission matrix as nested array (for testing/compatibility)

Source
epsilon
Source
label_count
Source
load_model(filename : String = "model.zip")
Source
lookup_table
Source
ngram_label_count
Source
ngrams_size

property initial_probabilities

Source
observation_space
Source
predicted_states
Source
prior_ngram_label_count
Source
save_model(filename : String = "model.zip")
Source
sequence_of_ngrams
Source
sequence_of_observations
Source
sequence_of_prior_ngrams
Source
state_space
Source
token_count

observation_space, state_space, initial_probabilities, sequence_of_observations, transition_matrix, emission_matrix

Source
token_label_count
Source
train(training_data : Array(Tuple(String, String)))
Source
training_data
Source
transition_matrix
Source
transition_matrix_to_a

Helper to get transition matrix as nested array (for testing/compatibility)

Source