- | `Auto(a) -> `NodeSet(ignore (Automaton.dump Format.err_formatter a;
- Tree.Binary.print_xml_fast stderr tree;
- Printf.eprintf "\n=======================\n%!";
- Automaton.TopDown.run a tree);
- Printf.eprintf "Results : %i\n%!"
- (Automaton.BST.cardinal a.Automaton.result);
- Automaton.BST.iter (fun t -> Tree.Binary.print_xml_fast stderr t;
- Printf.eprintf "^^^^^^^^^^^^^^^^^^^^^^^^\n%!")
- a.Automaton.result;
- a.Automaton.result)
+ | `Auto(a) -> `NodeSet(ignore (Automaton.BottomUp.accept a tree);
+ a.Automaton.result)
+ | `Contains(args) ->
+ begin
+ match args with
+ [ `Auto(a); `String(s) ] ->
+ let docs = try
+ Hashtbl.find a.Automaton.contains s
+ with
+ | Not_found ->
+ let r = Tree.Binary.contains tree s
+ in
+ (* Tree.Binary.DocIdSet.iter (fun id ->
+ Printf.eprintf "%s matches %s\n%!" (Tree.Binary.get_string tree id) s) r; *)
+
+ Hashtbl.add a.Automaton.contains s r;r
+ in
+ let _ = Automaton.BottomUp.accept ~strings:(Some docs) a tree
+ in `NodeSet(a.Automaton.result)
+ | _ -> failwith "contains invalid"
+ end