Commit b7ca94ed authored by Bruno Guillaume's avatar Bruno Guillaume

enriched grep mode (produces dep files)

parent c1ecd2fd
true: package(yojson, containers, str, ANSITerminal, log, conll)
true: bin_annot
\ No newline at end of file
true: bin_annot
......@@ -20,6 +20,7 @@ module Grew_args = struct
let grs = ref None
let gui_doc = ref false
let old_grs = ref false
let dep_dir = ref None
let (input_data : string option ref) = ref None
let (output_file : string option ref) = ref None
......@@ -112,6 +113,7 @@ module Grew_args = struct
| "-debug" :: args -> libgrew_debug_mode (); loop args
| "-debug_loop" :: args -> Rewrite.set_debug_loop ()
| "-dep_dir" :: dir :: args -> dep_dir := Some dir
| x -> Log.fwarning "Ignored arguments: %s" (String.concat " " x)
......
......@@ -90,14 +90,37 @@ let transform () =
(* get the array of graphs to explore *)
let graph_array = Corpus.get_graphs ?domain data_file in
(match !Grew_args.dep_dir with
| None -> ()
| Some d -> ignore (Sys.command (sprintf "mkdir -p %s" d)));
(* printf "%s\n" (String.concat "_" (Pattern.pid_name_list pattern)); *)
let pattern_ids = Pattern.pid_name_list pattern in
Array.iter
(fun (name,graph) ->
let matchings = Graph.search_pattern ?domain pattern graph in
List.iter
(fun matching ->
let node_matching = Graph.node_matching pattern graph matching in
let graph_node_id = List.assoc node_id node_matching in
printf "%s\t%g\n" name graph_node_id
let graph_node_ids = List.map snd node_matching in
let deco = Deco.build pattern matching in
let html = Graph.to_sentence ~deco graph in
let id = sprintf "%s__%s"
name
(String.concat "_" (List.map2 (sprintf "%s:%g") pattern_ids graph_node_ids)) in
(* let graph_node_id = List.assoc node_id node_matching in *)
(* printf "%s\t%g\n" name graph_node_id; *)
printf "%s@@%s\n" id html;
(match !Grew_args.dep_dir with
| None -> ()
| Some dir ->
let dep = Graph.to_dep ~deco graph in
let filename = sprintf "%s.dep" id in
let out_ch = open_out (Filename.concat dir filename) in
fprintf out_ch "%s" dep;
close_out out_ch
)
) matchings
) graph_array
) ()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment