def __init__(self, G, args, alpha=0.90, palpha=0.90): LOTHypothesis.__init__(self, G) self.lex = dict() self.grammar = G self.args = args self.alpha = alpha self.palpha = palpha
def __init__(self, grammar, value=None, rrAlpha=1.0, *args, **kwargs): """ Everything is passed to LOTHypothesis """ self.rrAlpha = rrAlpha LOTHypothesis.__init__(self, grammar, value=value, *args, **kwargs)
def __init__(self, grammar, nsamples=100, sm=0.001, **kwargs): """ kwargs should include ll_sd """ self.nsamples = nsamples self.sm = sm LOTHypothesis.__init__(self, grammar, **kwargs) # this is simple-generative since args=[] (a thunk)
def __init__(self, grammar=None, value=None, rrAlpha=1.0, *args, **kwargs): """ Everything is passed to LOTHypothesis """ self.rrAlpha = rrAlpha LOTHypothesis.__init__(self, grammar, value=value, *args, **kwargs)
def __init__(self, grammar, nsamples=100, **kwargs): """ kwargs should include ll_sd """ assert kwargs.get( 'args', None) is None, "Cannot specify args to SimpleGenerativeHypothesis" self.nsamples = nsamples LOTHypothesis.__init__( self, grammar, args=[], **kwargs) # this is simple-generative since args=[] (a thunk)
def __init__(self, grammar, recurse_bound=25, display="lambda recurse_, x: %s", **kwargs): """ Initializer. recurse gives the name for the recursion operation internally. """ assert "lambda recurse_" in display, "*** RecursiveLOTHypothesis must have 'recurse_' as first display element." # otherwise it can't eval # save recurse symbol self.recursive_depth_bound = recurse_bound # how deep can we recurse? self.recursive_call_depth = 0 # how far down have we recursed? LOTHypothesis.__init__(self, grammar, display=display)
def __init__(self, grammar, recurse='recurse_', recurse_bound=25, args=['x'], **kwargs): """ Initializer. recurse gives the name for the recursion operation internally. """ # save recurse symbol self.recurse = recurse self.recursive_depth_bound = recurse_bound # how deep can we recurse? self.recursive_call_depth = 0 # how far down have we recursed? # automatically put 'recurse' onto kwargs['args'] assert recurse not in args # not already specified args = [recurse] + args LOTHypothesis.__init__(self, grammar, args=args, **kwargs)
def __init__(self, grammar, recurse='recurse_', recurse_bound=25, args=['x'], **kwargs): """ Initializer. recurse gives the name for the recursion operation internally. """ # save recurse symbol self.recurse = recurse self.recursive_depth_bound = recurse_bound # how deep can we recurse? self.recursive_call_depth = 0 # how far down have we recursed? # automatically put 'recurse' onto args assert recurse not in args # not already specified args = [recurse] + args LOTHypothesis.__init__(self, grammar, args=args, **kwargs)
def __call__(self, *args): """ The main calling function. Resets recursive_call_depth and then calls """ self.recursive_call_depth = 0 # call with passing self.recursive_Call as the recursive call return LOTHypothesis.__call__(self, self.recursive_call, *args)
def recursive_call(self, *args): """ This gets called internally on recursive calls. It keeps track of the depth to allow us to escape """ self.recursive_call_depth += 1 if self.recursive_call_depth > self.recursive_depth_bound: raise RecursionDepthException return LOTHypothesis.__call__(self, *args)
def recursive_call(self, *args): """ This gets called internally on recursive calls. It keeps track of the depth and throws an error if you go too deep """ self.recursive_call_depth += 1 if self.recursive_call_depth > self.recursive_depth_bound: raise RecursionDepthException # Call with sending myself as the recursive call return LOTHypothesis.__call__(self, self.recursive_call, *args)
def __call__(self, *args): """ The main calling function. Resets recursive_call_depth and then calls """ self.recursive_call_depth = 0 return LOTHypothesis.__call__(self, *args)
def __init__(self, G, nsamples=100, **kwargs): """ kwargs should include ll_sd """ assert kwargs.get('args', None) is None, "Cannot specify args to SimpleGenerativeHypothesis" self.nsamples=nsamples LOTHypothesis.__init__(self, G, args=[], **kwargs) # this is simple-generative since args=[] (a thunk)
def __init__(self, grammar, value=None, f=None, prior_temperature=1.0, proposal_function=None, **kwargs): self.__dict__.update(locals()) # must come first or else proposal_function is overwritten LOTHypothesis.__init__(self, grammar, value=value, f=f, proposal_function=proposal_function, **kwargs)