def make_set_head_from(l, r, p): L, R, P = l.cat, r.cat, p.cat for ll,rr,pp in zip(L.nested_compound_categories(),R.nested_compound_categories(),P.nested_compound_categories()): if ll.slot.head.lex and rr.slot.head.lex: pp.slot.head.lex = list(flatten((ll.slot.head.lex, rr.slot.head.lex))) else: unify(ll,rr,copy_vars=True,ignore=True) unify(rr,pp,ignore=True) copy_vars(rr,pp)
def do_with(self, args): '''Changes or displays the working set.''' args = args.split() if args: self.files = [] for arg in args: # So that if arg is not a glob, it won't get removed # because it doesn't exist on the fs: globbed = list(flatten(glob.glob(arg))) if globbed: self.files += globbed else: self.files.append(arg) msg("Working set is: " + list_preview(self.files))
# cache the last locator sequence so it can be referred to quickly last_locator_bits = None for (sec, doc), commands in group_by_derivation( parse_instruction_lines(sys.stdin.readlines())): cur_trees = load_trees(base, sec, doc, extension, guessers_to_use) for ((_, _, deriv), command) in commands: print command cur_bundle = cur_trees[deriv] locator, instr = command.split(' ', 2) locator_bits = list( flatten( map( compose( maybe_int, lambda value: desugar( value, last_locator_bits, cur_bundle.derivation)), locator.split(';')))) cur_bundle.derivation = process(cur_bundle.derivation, locator_bits, instr) last_locator_bits = locator_bits # Write tree back here write_doc(opts.out, extension, sec, doc, cur_trees)
def group_by_derivation(lines): def doc_comparator( ( (sec, doc, deriv), line) ): return (sec, doc) def spec_comparator( ( spec, line ) ): return spec return groupby(sorted(lines, key=spec_comparator), doc_comparator) # cache the last locator sequence so it can be referred to quickly last_locator_bits = None for (sec, doc), commands in group_by_derivation(parse_instruction_lines(sys.stdin.readlines())): cur_trees = load_trees(base, sec, doc, extension, guessers_to_use) for ((_, _, deriv), command) in commands: print command cur_bundle = cur_trees[deriv] locator, instr = command.split(' ', 2) locator_bits = list(flatten(map( compose(maybe_int, lambda value: desugar(value, last_locator_bits, cur_bundle.derivation)), locator.split(';')))) cur_bundle.derivation = process(cur_bundle.derivation, locator_bits, instr) last_locator_bits = locator_bits # Write tree back here write_doc(opts.out, extension, sec, doc, cur_trees)