def test_spelling(self): # Assert spelling suggestion accuracy. i = j = 0.0 from pattern.db import Datasheet for correct, wrong in Datasheet.load(os.path.join(PATH, "corpora", "birkbeck-spelling.csv")): for w in wrong.split(" "): if en.spelling(w)[0][0] == correct: i += 1 else: j += 1 self.assertTrue(i / (i+j) > 0.70)
def test_spelling(self): # Assert spelling suggestion accuracy. # Note: simply training on more text will not improve accuracy. i = j = 0.0 from pattern.db import Datasheet for correct, wrong in Datasheet.load(os.path.join(PATH, "corpora", "spelling-birkbeck.csv")): for w in wrong.split(" "): if en.spelling(w)[0][0] == correct: i += 1 else: j += 1 self.assertTrue(i / (i+j) > 0.70)
def test_spelling(self): # Assert spelling suggestion accuracy. # Note: simply training on more text will not improve accuracy. i = j = 0.0 from pattern.db import Datasheet for correct, wrong in Datasheet.load(os.path.join(PATH, "corpora", "birkbeck-spelling.csv")): for w in wrong.split(" "): if en.spelling(w)[0][0] == correct: i += 1 else: j += 1 self.assertTrue(i / (i+j) > 0.70)
def sp(self, tokens): correct_word = spelling(tokens) return (correct_word)
from pattern.en import spelling word = "amazng" correct_word = spelling(word) print(correct_word)