def evaluate_tagger_and_writeout(tagger): stdin = conllu.reader() stdout = conllu.writer() for sentence in stdin: x = [] for word in sentence: x.append(tagger.vocab.get(TaggingDataset.word_obj_to_str(word), tagger.vocab['#OOV'])) x = np.array([x], dtype='int32') y_hat = tagger.predict(x)[0] y_hat_str = [tagger.tags.rev(tag_id) for tag_id in y_hat] for word, utag in zip(sentence, y_hat_str): word.upos = utag stdout.write_sentence(sentence)
def evaluate_tagger_and_writeout(tagger): stdin = conllu.reader() stdout = conllu.writer() for sentence in stdin: x = [] for word in sentence: x.append( tagger.vocab.get(TaggingDataset.word_obj_to_str(word), tagger.vocab['#OOV'])) x = np.array([x], dtype='int32') y_hat = tagger.predict(x)[0] y_hat_str = [tagger.tags.rev(tag_id) for tag_id in y_hat] for word, utag in zip(sentence, y_hat_str): word.upos = utag stdout.write_sentence(sentence)