def __init__(self, s, category_hinter, line_number=None ): ''' Attempt to disambiguate assuming a maximum of two numbers This resolves if there is a single unambiguous break-point in the middle of the string, or if only one number can be formed through concatenation, such that it cannot be broken down further without making it smaller than the concatenation of the remaining string. This is the fallback resolution method, and returns a multi-element ambiguous number at the point where resolution fails. ''' lineList.__init__(self, s, category_hinter, line_number=line_number ) for pos in range(0,len(self),1): self[pos] = self.attempt_merge( self[pos] )
def __init__(self, s, category_hinter, line_number=None): """ Attempt to disambiguate assuming a cross-total exists This resolves if three numbers exist in a cluster such that the third is the difference of the first two. Resolution either works or it doesn't; the value returned is an ambiguousCluster with a single value, or an empty string. """ lineList.__init__(self, s, category_hinter, line_number=line_number) for pos in range(len(self)-1,-1,-1): cluster = self[pos] income = None if len(cluster) > 2: income = self.cross_total( cluster ) if income == None and len(cluster) > 1: income = self.paired_numbers( cluster ) if income == None: self.pop(pos) continue self[pos] = ambiguousCluster( income, {} ) self.max_only()