def test_ignorecase_false_2(self): s = synonyms.load(open(synfile), ignoreCase=False) self.assertEqual(s.match('Rock'), 'Rock')
def test_load_list(self): f = [['USA', 'United States'], ['Rock','boulder', 'pebble']] s = synonyms.load(f) self.assertEqual(s.match('boulder'), 'rock')
def test_ignorecase_true_2(self): s = synonyms.load(open(synfile)) self.assertEqual(s.match('united states'), 'usa')
def test_ignorecase_false_1(self): s = synonyms.load(open(synfile), ignoreCase=False) self.assertEqual(s.match('BoulDer'), None)
def test_ignorecase_true_1(self): s = synonyms.load(open(synfile)) self.assertEqual(s.match('BoulDer'), 'rock')
def test_in(self): s = synonyms.load(open(synfile)) self.assertTrue('uSa' in s)
def test_load_str(self): fp = open(synfile) f = fp.read() s = synonyms.load(f) self.assertEqual(s.match('boulder'), 'rock')
def test_load_file(self): fp = open(synfile) s = synonyms.load(fp) self.assertEqual(s.match('boulder'), 'rock')
spintax += token spintax += "|" for x in range(n): spintax += syn[x] if x < n-1: spintax += "|" else: spintax += "} " return spintax class Magic: def __init__(self, nlib): self.lib = nlib self.tool = language_check.LanguageTool('en-US') def __call__(self, inp): s = spinner() s.getlib(self.lib) spintax = s.getSpintax(inp[0]) spun = s.spin(spintax) text = spun matches = self.tool.check(text) result = language_check.correct(text, matches) return result if __name__ == '__main__': lib = load(open( os.getcwd() + '/modules/py/vocab.txt')) magic = Magic(lib) text = sys.stdin.readlines() print( magic(text) )