Commit bde4797f authored by bguillaum's avatar bguillaum
Browse files

add function for gr saving with deterministic grs (for -dep mode of grewui)

git-svn-id: svn+ssh:// 7838e531-6607-4d57-9587-6c381814729c
parent a8ea123a
......@@ -55,6 +55,14 @@ module Rewrite_history = struct
| l, _ -> List_.iteri (fun i son -> loop (sprintf "%s_%d" file_name i) son) l
in loop base 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
| _ -> "Not a single rewriting"
in loop t
......@@ -26,7 +26,13 @@ module Rewrite_history: sig
t ->
((string * string list) list * string) list
(** [save_gr base_name t] saves one gr_file for each normal form defined in [t].
Output files are named according to [base_name] and the Gorn adress in the rewriting tree. *)
val save_gr: 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
module Modul: sig
......@@ -145,6 +145,9 @@ let save_index ~dirname ~base_names =
let save_gr base rew_hist =
Rewrite_history.save_gr base rew_hist
let save_det_gr base rew_hist =
Rewrite_history.save_det_gr base rew_hist
let write_html
......@@ -52,6 +52,8 @@ val to_sentence: ?main_feat:string -> Instance.t -> string
val save_gr: string -> Rewrite_history.t -> unit
val save_det_gr: string -> Rewrite_history.t -> unit
(** get a graph from a file either in 'gr' or 'conll' format.
File extension should be '.gr' or '.conll'.
@raise Parsing_err if libgrew can't parse the file
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