5 let set_index_type = function
6 | "default" -> text_index_type := 0
7 | "swcsa" -> text_index_type := 1
8 | "rlcsa" -> text_index_type := 2
9 | s -> raise (Arg.Bad(s))
11 let usage_msg = Printf.sprintf "%s [options] <input.{xml|srx}> 'query' [output]" Sys.argv.(0)
15 fun s -> match !pos with
16 | 0 -> input_file:= s;incr pos
17 | 1 -> query := s; incr pos
18 | 2 -> output_file := Some s; incr pos
19 | _ -> raise (Arg.Bad(s))
25 match String.explode t ':' with
27 let l = try int_of_string lvl with _ -> raise (Arg.Bad (lvl)) in
28 if Logger.is_logger tr then Logger.activate tr l
29 else raise (Arg.Bad (t))
30 | _ -> raise (Arg.Bad (t))
31 ) (String.explode s ',')
33 let pretty_loggers () =
34 ignore(flush_str_formatter());
37 (fun f s -> fprintf f "%s" s)
39 (Logger.available ());
40 flush_str_formatter ()
43 [ "-c", Arg.Set(count_only),
44 " counting only (don't materialize the result set)";
46 "-two", Arg.Set(twopass),
47 " Use twopass algorithm";
49 "-f", Arg.Set_int(sample_factor),
50 "<n> sample factor [default=64]";
52 "-ne", Arg.Clear(index_empty_texts),
53 " don't index empty texts [default=index]";
55 "-d", Arg.Set(disable_text_collection),
56 " disable text collection[default=false]";
58 "-s", Arg.Set_string(save_file),
59 "<save_file> save the intermediate representation into file.srx";
61 "-b", Arg.Set(bottom_up), " real bottom up run";
63 "-nj", Arg.Set(no_jump), " disable jumping";
65 "-nc", Arg.Set(no_cache), " disable caching";
67 "-nw", Arg.Set(no_wrap_results), " do not wrap results in <xml_results/>";
69 "-p", Arg.Set(do_perf), " dump perf counters (Linux only)";
71 "-index-type", Arg.Symbol ([ "default"; "swcsa"; "rlcsa" ],
73 " choose text index type";
75 "-r", Arg.Set_int(repeat),
76 " repeat query execution n time (benchmarking only, default 1)";
78 "-doc-stats", Arg.Set(docstats),
79 " Compute document statistics (performs full traversal)";
82 "-v", Arg.Set(verbose), " verbose mode"; ] @
85 "-log", Arg.String (set_logger),
86 "<logger1:l1,...,loggern:ln> enable logging with the specified level. Valid loggers are: "
94 let _ = Arg.parse spec anon_fun usage_msg
96 if (!pos > 3 || !pos < 2)
97 then begin Arg.usage spec usage_msg; exit 1 end;
98 Logger.set_verbose !verbose