コード例 #1
0
	def test_words(self):
		''' Tests that the words in the text file have syllables in the dictionary '''
		tc = open('syllable/cases.txt')
		for line in tc:
			# format is: word syllables
			ls = line.split()
			word = ls[0]
			syllables = int(ls[1])
			print "word, syllables: ", word, syllables
			self.assertEqual(sylla.syllables(word), syllables)
コード例 #2
0
	def test_names(self):
		''' Test names (using the heuristic) '''
		self.assertEqual(sylla.syllables('yuki'), 2)
		self.assertEqual(sylla.syllables('paul'), 1)
コード例 #3
0
	def test_nonwords(self):
		''' Test non-english words '''
		self.assertEqual(sylla.syllables('lol'), 1)
		self.assertEqual(sylla.syllables('haha'), 2)
		self.assertEqual(sylla.syllables('wtf'), 1)