def test_generate_possible_words(self):
		ra = ReverseAutocorrect()
		canidates = set(['a'])
		canidates = ra._generate_possible_words(canidates, 1)
		self.assertEqual(len(canidates), 78)

		canidates = set(['ab'])
		canidates = ra._generate_possible_words(canidates, 1)
		self.assertEqual(len(canidates), 129)
예제 #2
0
    def test_generate_possible_words(self):
        ra = ReverseAutocorrect()
        canidates = set(['a'])
        canidates = ra._generate_possible_words(canidates, 1)
        self.assertEqual(len(canidates), 78)

        canidates = set(['ab'])
        canidates = ra._generate_possible_words(canidates, 1)
        self.assertEqual(len(canidates), 129)
	def test_generate_words(self):
		ra = ReverseAutocorrect()
		words = ra._generate_words('capital', 2)
		self.assertEqual(len(words), 6)
		self.assertTrue('capitis' in words)
		self.assertTrue('capitol' in words)
		self.assertTrue('capitals' in words)
		self.assertTrue('cubital' in words)
		self.assertTrue('capitale' in words)
		self.assertTrue('capitally' in words)
예제 #4
0
 def test_generate_words(self):
     ra = ReverseAutocorrect()
     words = ra._generate_words('capital', 2)
     self.assertEqual(len(words), 6)
     self.assertTrue('capitis' in words)
     self.assertTrue('capitol' in words)
     self.assertTrue('capitals' in words)
     self.assertTrue('cubital' in words)
     self.assertTrue('capitale' in words)
     self.assertTrue('capitally' in words)
	def test_read_corpus(self):
		f = open('_test_file', 'w')
		f.write('Testing testing I\'ll i\'ll word\n')
		f.close()

		ra = ReverseAutocorrect()
		model, _ = ra._read_corpus('_test_file')
		os.remove('_test_file')
		self.assertEqual(model['testing'], 3)
		self.assertEqual(model['i\'ll'], 3)
		self.assertEqual(model['word'], 2)
		self.assertEqual(model['blank'], 1)
예제 #6
0
    def test_read_corpus(self):
        f = open('_test_file', 'w')
        f.write('Testing testing I\'ll i\'ll word\n')
        f.close()

        ra = ReverseAutocorrect()
        model, _ = ra._read_corpus('_test_file')
        os.remove('_test_file')
        self.assertEqual(model['testing'], 3)
        self.assertEqual(model['i\'ll'], 3)
        self.assertEqual(model['word'], 2)
        self.assertEqual(model['blank'], 1)
예제 #7
0
def main():
	print 'Welcome to Reverse Autocorrect'
	sentence = raw_input("Please enter a sentence: ")
	ra = ReverseAutocorrect()
	print ra.generate_sentence(sentence)
예제 #8
0
def main():
    print 'Welcome to Reverse Autocorrect'
    sentence = raw_input("Please enter a sentence: ")
    ra = ReverseAutocorrect()
    print ra.generate_sentence(sentence)