Views
No views yet
not so good with the sequence of words).1from transformers import AutoTokenizer, TFBartForConditionalGeneration
2tokenizer = AutoTokenizer.from_pretrained("veghar/spell_correct_bart_base")
3model = TFBartForConditionalGeneration.from_pretrained("veghar/spell_correct_bart_base")
4
5text='believ'
6text_tok=tokenizer(text,padding=True, return_tensors='tf')
7input_ids = text_tok['input_ids']
8outputs = model.generate(input_ids=input_ids, max_length=10,num_return_sequences=3)
9corrected_sentences = tokenizer.batch_decode(outputs, skip_special_tokens=True)
10
11print('Misspelled word:', text)
12print('Corrected word:', corrected_sentences)
13
14
15>>Misspelled word: believ
16>>Corrected word: ['believe', 'belief', 'believer']