예제 #1
0
 def test_ignorecase_false_2(self):
     s = synonyms.load(open(synfile), ignoreCase=False)
     self.assertEqual(s.match('Rock'), 'Rock')
예제 #2
0
 def test_load_list(self):
     f = [['USA', 'United States'],
          ['Rock','boulder', 'pebble']]
     s = synonyms.load(f)
     self.assertEqual(s.match('boulder'), 'rock')
예제 #3
0
 def test_ignorecase_true_2(self):
     s = synonyms.load(open(synfile))
     self.assertEqual(s.match('united states'), 'usa')
예제 #4
0
 def test_ignorecase_false_1(self):
     s = synonyms.load(open(synfile), ignoreCase=False)
     self.assertEqual(s.match('BoulDer'), None)
예제 #5
0
 def test_ignorecase_true_1(self):
     s = synonyms.load(open(synfile))
     self.assertEqual(s.match('BoulDer'), 'rock')
예제 #6
0
 def test_in(self):
     s = synonyms.load(open(synfile))
     self.assertTrue('uSa' in s)
예제 #7
0
 def test_load_str(self):
     fp = open(synfile)
     f = fp.read()
     s = synonyms.load(f)
     self.assertEqual(s.match('boulder'), 'rock')
예제 #8
0
 def test_load_file(self):
     fp = open(synfile)
     s = synonyms.load(fp)
     self.assertEqual(s.match('boulder'), 'rock')
예제 #9
0
                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) )