print >> sys.stderr, ct, "..." ct += 1 fields = line.strip().split() (lhs, arrow, rhs1) = fields[0:3] assert arrow == "->" if len(fields) == 5: rhs = [rhs1, fields[3]] prob = fields[4] elif len(fields) == 4: rhs = [rhs1] prob = fields[3] prob = float(prob) rule = Rule() rule.setup(lhs, rhs, prob) if [rule.lhs] == rule.rhs and rule.prob == 1.0: print >> sys.stderr, "Warning: X->X", rule.lhs, rule.rhs else: rules[rule.lhs].append(rule) ct = 0 for line in file(lexicon): if ct % 1000 == 0: print >> sys.stderr, ct, "..." ct += 1 fields = line.strip().split() (pos, word) = fields[0:2]
def __init__(self, level, string=None): Rule.__init__(self, string) self.children = [] self.level = level