Python, NLP, Numpy, Scikit Learn.
1.0 for each token that appears in the sentence. class OneHotEncoder(SciKitTransformer): def __init__(self, vocab): self.vocab_dict = dict.fromkeys(vocab, 0.0) def one_hot_vector(self, tokens): vec_dict = deepcopy(self.vocab_dict) for token in tokens: if token in self.vocab_dict: vec_dict[token] =