def __init__(self, candidate, index, length, decoder, parent=None):
self.decoder = decoder #the decoder provides the necessary context, it is in turn tied to the corrector
self.parent = parent #links to the parent hypothesis that generated this one
self.candidate = candidate #or None for the initial root hypothesis
self.index = index #the position of the last added candidate in the original testtokens sequence
self.length = length #the length of the last added candidate
#if parent is None:
# self.covered = np.zeros(len(self.decoder), dtype=np.byte)
#else:
# self.covered = self.parent.covered.copy()
# self.covered[self.index:self.index+self.length+1] = 1
self.logprob = self.computeprob()
if self.decoder.corrector.args.debug:
print("[DEBUG] Generated Hypothesis " + repr(self), file=sys.stderr)
评论列表
文章目录