Commit 66740159 authored by bguillaum's avatar bguillaum

add "filter" optional arg to control the display of feature structures

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@7855 7838e531-6607-4d57-9587-6c381814729c
parent fc2e3441
......@@ -28,11 +28,11 @@ module Rewrite_history = struct
| { good_nf = l} -> List.fold_left (fun acc t -> acc + (num_sol t)) 0 l
let save_nfs ?main_feat ~dot base_name t =
let save_nfs ?filter ?main_feat ~dot base_name t =
let rec loop file_name rules t =
match (t.good_nf, t.bad_nf) with
| [],[] when dot -> Instance.save_dot_png ?main_feat file_name t.instance; [rules, file_name]
| [],[] -> Instance.save_dep_png ?main_feat file_name t.instance; [rules, file_name]
| [],[] when dot -> Instance.save_dot_png ?filter ?main_feat file_name t.instance; [rules, file_name]
| [],[] -> Instance.save_dep_png ?filter ?main_feat file_name t.instance; [rules, file_name]
| [],_ -> []
| l, _ ->
List_.foldi_left
......
......@@ -20,6 +20,7 @@ module Rewrite_history: sig
- returns a list of couples (rules, file)
*)
val save_nfs:
?filter: string list ->
?main_feat: string ->
dot: bool ->
string ->
......
......@@ -463,16 +463,16 @@ module Html_doc = struct
end
module Html_rh = struct
let build ?main_feat ?(dot=false) ?(init_graph=true) ?(out_gr=false) ?header ~graph_file prefix t =
let build ?filter ?main_feat ?(dot=false) ?(init_graph=true) ?(out_gr=false) ?header ~graph_file prefix t =
(* remove files from previous runs *)
let _ = Unix.system (sprintf "rm -f %s*.html" prefix) in
let _ = Unix.system (sprintf "rm -f %s*.dep" prefix) in
let _ = Unix.system (sprintf "rm -f %s*.png" prefix) in
(if init_graph then Instance.save_dep_png ?main_feat prefix t.Rewrite_history.instance);
(if init_graph then Instance.save_dep_png ?filter ?main_feat prefix t.Rewrite_history.instance);
let nf_files = Rewrite_history.save_nfs ?main_feat ~dot prefix t in
let nf_files = Rewrite_history.save_nfs ?filter ?main_feat ~dot prefix t in
let l = List.length nf_files in
......
......@@ -15,6 +15,7 @@ end
module Html_rh: sig
val build:
?filter: string list ->
?main_feat: string ->
?dot: bool ->
?init_graph:bool ->
......
......@@ -53,14 +53,14 @@ module Instance = struct
let to_conll t = G_graph.to_conll t.graph
let save_dot_png ?main_feat base t =
let save_dot_png ?filter ?main_feat base t =
ignore (Grew_utils.png_file_from_dot (G_graph.to_dot ?main_feat t.graph) (base^".png"))
IFDEF DEP2PICT THEN
let save_dep_png ?main_feat base t =
ignore (Dep2pict.Dep2pict.fromDepStringToPng (G_graph.to_dep ?main_feat t.graph) (base^".png"))
let save_dep_png ?filter ?main_feat base t =
ignore (Dep2pict.Dep2pict.fromDepStringToPng (G_graph.to_dep ?filter ?main_feat t.graph) (base^".png"))
ELSE
let save_dep_png ?main_feat base t = ()
let save_dep_png ?filter ?main_feat base t = ()
ENDIF
end (* module Instance *)
......
......@@ -34,10 +34,10 @@ module Instance : sig
(** [save_dep_png base t] writes a file "base.png" with the dep representation of [t].
NB: if the Dep2pict is not available, nothing is done *)
val save_dep_png: ?main_feat: string -> string -> t -> unit
val save_dep_png: ?filter: string list -> ?main_feat: string -> string -> t -> unit
(** [save_dot_png base t] writes a file "base.png" with the dot representation of [t] *)
val save_dot_png: ?main_feat: string -> string -> t -> unit
val save_dot_png: ?filter: string list -> ?main_feat: string -> string -> t -> unit
end
module Instance_set : Set.S with type elt = Instance.t
......
......@@ -170,7 +170,8 @@ let det_dep_string rew_hist = Rewrite_history.det_dep_string rew_hist
let write_html
?(no_init=false)
?(out_gr=false)
?main_feat
?filter
?main_feat
?dot
~header
~graph_file
......@@ -178,6 +179,7 @@ let write_html
output_base =
ignore (
Html_rh.build
?filter
?main_feat
?dot
~out_gr
......
......@@ -58,7 +58,7 @@ val save_conll: string -> Rewrite_history.t -> unit
val save_det_gr: string -> Rewrite_history.t -> unit
val save_det_conll: string -> Rewrite_history.t -> unit
val save_det_conll: ?header:string -> string -> Rewrite_history.t -> unit
val det_dep_string: Rewrite_history.t -> string
......@@ -86,6 +86,7 @@ val save_index: dirname:string -> base_names: string list -> unit
val write_html:
?no_init: bool ->
?out_gr: bool ->
?filter: string list ->
?main_feat: string ->
?dot: bool ->
header: string ->
......
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