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
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
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
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