Commit b489623a authored by bguillaum's avatar bguillaum

version 0.25: add support for the [-full] mode

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@8580 7838e531-6607-4d57-9587-6c381814729c
parent 74a9f052
VERSION = 0.24.0
VERSION = 0.25.0
INSTALL_DIR_LIB = @OCAMLLIB@
INSTALL_DIR = @prefix@/bin/
......
......@@ -71,13 +71,23 @@ module Rewrite_history = struct
| l, _ -> List_.iteri (fun i son -> loop (sprintf "%s_%d" file_name i) son) l
in loop base t
let save_full_conll base t =
let cpt = ref 0 in
let rec loop t =
match (t.good_nf, t.bad_nf) with
| [],[] ->
File.write (Instance.to_conll t.instance) (sprintf "%s__%d.conll" base !cpt);
incr cpt
| l, _ -> List.iter loop l
in loop t
(* suppose that all modules are confluent and produced exacly one normal form *)
let save_det_gr base t =
let rec loop t =
match (t.good_nf, t.bad_nf) with
| [],[] -> File.write (Instance.to_gr t.instance) (base^".gr")
| [one], [] -> loop one
| _ -> Error.run "Not a single rewriting"
| _ -> Error.run "[save_det_gr] Not a single rewriting"
in loop t
let save_annot out_dir base_name t =
......@@ -105,7 +115,7 @@ module Rewrite_history = struct
| None -> Instance.to_conll t.instance in
File.write output (base^".conll")
| ([one], []) -> loop one
| _ -> Error.run "Not a single rewriting"
| _ -> Error.run "[save_det_conll] Not a single rewriting"
in loop t
let det_dep_string t =
......@@ -270,6 +280,7 @@ module Grs = struct
| [] -> (* no more modules to apply *)
{Rewrite_history.instance = instance; module_name = ""; good_nf = []; bad_nf = []; }
| next::tail ->
(* printf "Enter module ==> %s\n%!" next.Modul.name; *)
let (good_set, bad_set) =
Rule.normalize
next.Modul.name
......
......@@ -46,6 +46,10 @@ module Rewrite_history: sig
val save_gr: string -> t -> unit
val save_conll: string -> t -> unit
(** [save_full_conll base_name t] saves one conll_file for each normal form defined in [t].
Output files are named according to [base_name] and a secondary index after "__". *)
val save_full_conll: string -> t -> unit
(** [save_det_gr base_name t] supposes that the current GRS is deterministic.
It writes exactly one output file named [base_name].gr with the unique normal form. *)
val save_det_gr: string -> t -> unit
......
......@@ -187,6 +187,9 @@ let save_gr base rew_hist =
let save_conll base rew_hist =
handle ~name:"save_conll" (fun () -> Rewrite_history.save_conll base rew_hist) ()
let save_full_conll base rew_hist =
handle ~name:"save_full_conll" (fun () -> Rewrite_history.save_full_conll base rew_hist) ()
let save_det_gr base rew_hist =
handle ~name:"save_det_gr" (fun () -> Rewrite_history.save_det_gr base rew_hist) ()
......
......@@ -79,6 +79,8 @@ val save_gr: string -> Rewrite_history.t -> unit
val save_conll: string -> Rewrite_history.t -> unit
val save_full_conll: string -> Rewrite_history.t -> unit
val save_det_gr: string -> Rewrite_history.t -> unit
val save_det_conll: ?header:string -> string -> Rewrite_history.t -> unit
......
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