예제 #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
예제 #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
예제 #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
예제 #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