Commit b27a1450 authored by bguillaum's avatar bguillaum

version 0.13: add the -out_gr option

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@7245 7838e531-6607-4d57-9587-6c381814729c
parent 0c94cbd6
VERSION = 0.12.1
VERSION = 0.13
INSTALL_DIR_LIB = @OCAMLLIB@
INSTALL_DIR = @prefix@/bin/
......
......@@ -80,7 +80,14 @@ module Rewrite_history = struct
Html.leave html_ch;
close_out html_ch
let save_html ?main_feat ?(init_graph=true) ?header ~graph_file prefix t =
let save_gr base t =
let rec loop file_name t =
match (t.good_nf, t.bad_nf) with
| [],[] -> File.write (Instance.to_gr t.instance) (file_name^".gr")
| l, _ -> List_.iteri (fun i son -> loop (sprintf "%s_%d" file_name i) son) l
in loop base t
let save_html ?main_feat ?(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
......@@ -120,6 +127,9 @@ module Rewrite_history = struct
let local_name = Filename.basename file_name in
if out_gr
then fprintf html_ch "<p><a href=\"%s.gr\">gr file</a>\n" local_name;
(* the png file *)
fprintf html_ch "<div width=100%% style=\"overflow-x:auto\"><IMG SRC=\"%s.png\"></div>\n" local_name;
......
......@@ -17,8 +17,18 @@ module Rewrite_history: sig
IFDEF DEP2PICT THEN
val error_html: ?main_feat:string -> ?init_graph:bool -> ?header:string -> string -> string -> Instance.t option -> unit
val save_html: ?main_feat:string -> ?init_graph:bool -> ?header:string -> graph_file:string -> string -> t -> unit
val save_html:
?main_feat:string ->
?init_graph:bool ->
?out_gr:bool ->
?header:string ->
graph_file:string ->
string ->
t ->
unit
ENDIF
val save_gr: string -> t -> unit
end
module Sequence: sig
......
......@@ -47,6 +47,8 @@ module Instance = struct
(* only graph rewrited from the same init graph can be "compared" *)
let compare t1 t2 = Pervasives.compare t1.commands t2.commands
let to_gr t = G_graph.to_gr t.graph
IFDEF DEP2PICT THEN
let save_dep_png ?main_feat base t =
ignore (Dep2pict.fromDepStringToPng (G_graph.to_dep ?main_feat t.graph) (base^".png"))
......
......@@ -26,6 +26,8 @@ module Instance : sig
val from_graph: G_graph.t -> t
val get_graph: t -> G_graph.t
val to_gr: t -> string
IFDEF DEP2PICT THEN
(* [save_dep_png base t] writes a file "base.png" with the dep representation of [t] *)
val save_dep_png: ?main_feat: string -> string -> t -> unit
......
......@@ -549,8 +549,8 @@ module Conll = struct
gov = int_of_string gov;
dep_lab = dep_lab;
}
| _ ->
Error.build ~loc:(file,line_num) "[Conll.load] illegal line \n>>>>>%s<<<<<<" line in
| l ->
Error.build ~loc:(file,line_num) "[Conll.load] illegal line, %d fields (10 are expected)\n>>>>>%s<<<<<<" (List.length l) line in
let lines = File.read_ln file in
List.map parse lines
......
......@@ -138,8 +138,12 @@ let save_index ~dirname ~base_names =
List.iter (fun f -> fprintf out_ch "%s\n" f) base_names;
close_out out_ch
let save_gr base rew_hist = Rewrite_history.save_gr base rew_hist
let write_html
?(no_init=false) ?main_feat
?(no_init=false)
?(out_gr=false)
?main_feat
~header
~graph_file
rew_hist
......@@ -147,7 +151,8 @@ let write_html
IFDEF DEP2PICT THEN
ignore (
Rewrite_history.save_html
?main_feat
?main_feat
~out_gr
~init_graph: (not no_init)
~header
~graph_file
......
......@@ -48,6 +48,8 @@ val get_sequence_names: Grs.t -> string list
val to_sentence: ?main_feat:string -> Instance.t -> string
val save_gr: string -> Rewrite_history.t -> unit
val empty_gr : Instance.t
(** get a graph from a file either in 'gr' or 'conll' format.
......@@ -60,7 +62,8 @@ val load_graph: string -> Instance.t
val save_index: dirname:string -> base_names: string list -> unit
val write_html:
?no_init:bool ->
?no_init:bool ->
?out_gr:bool ->
?main_feat:string ->
header: string ->
graph_file: 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