Exemplo n.º 1
0
	def ruleExists(self,rule):
		if not (isinstance(rule,str) or isinstance(rule,G1DBinaryString)):
			Util.raiseException("BitString expected as input", ValueError)
		if isinstance(rule,G1DBinaryString): rule = G1DBinaryString.getBinary()
		for lowerCut,upperCut in self.rulePartition:
			currentRule = ''.join(map(str,self.ruleSet[lowerCut:upperCut]))
			if (currentRule[:-1]==rule): return True
		return False
Exemplo n.º 2
0
 def ruleExists(self, rule):
     if not (isinstance(rule, str) or isinstance(rule, G1DBinaryString)):
         Util.raiseException("BitString expected as input", ValueError)
     if isinstance(rule, G1DBinaryString):
         rule = G1DBinaryString.getBinary()
     for lowerCut, upperCut in self.rulePartition:
         currentRule = ''.join(map(str, self.ruleSet[lowerCut:upperCut]))
         if (currentRule[:-1] == rule): return True
     return False
Exemplo n.º 3
0
	def getClassificationForRule(self,rule):
		if not (isinstance(rule,str) or isinstance(rule,G1DBinaryString)):
			Util.raiseException("BitString expected as input", ValueError)
		if isinstance(rule,G1DBinaryString): rule = G1DBinaryString.getBinary()
		for lowerCut,upperCut in self.rulePartition:
			fullRule = ''.join(map(str,self.ruleSet[lowerCut:upperCut]))
			#current rule is obtained by ignoring the last classification bit
			currentRule = fullRule[:-1]
			if (currentRule==rule): return fullRule[-1] #last bit corresponds to the classification
		return None
Exemplo n.º 4
0
 def getClassificationForRule(self, rule):
     if not (isinstance(rule, str) or isinstance(rule, G1DBinaryString)):
         Util.raiseException("BitString expected as input", ValueError)
     if isinstance(rule, G1DBinaryString):
         rule = G1DBinaryString.getBinary()
     for lowerCut, upperCut in self.rulePartition:
         fullRule = ''.join(map(str, self.ruleSet[lowerCut:upperCut]))
         #current rule is obtained by ignoring the last classification bit
         currentRule = fullRule[:-1]
         if (currentRule == rule):
             return fullRule[
                 -1]  #last bit corresponds to the classification
     return None