Ejemplo n.º 1
0
	def test_complexity(self):
		#upper bound the complexity value: encode number of states, number of arcs
		#each arc, each stop (with no stop for a state as 0), number of stops
		state = wfsa.integer_code_len(3)
		arc = wfsa.integer_code_len(6)
		stop = wfsa.integer_code_len(2)
		single_arc = 3*log(3,2)+64
		single_stop = log(3,2)+64
		complexity = 6*single_arc + 3*single_stop + arc + state + stop
		self.assert_( self.fsa1.complexity <= complexity )
				
		self.arcs['0']['a'] = ('0', 0.0)
		fsa3 = wfsa.MultWFSA( self.fsa1.alphabet, self.fsa1.start[0], self.stop, 
			self.arcs, zero = True )
		self.assert_( fsa3.complexity, self.fsa1.complexity )
Ejemplo n.º 2
0
	def test_int_code(self):
		self.assertAlmostEquals(wfsa.integer_code_len(3), 3.767978574539)
		self.assertAlmostEquals(wfsa.integer_code_len(4), 4.518567366364)