Commit 38686d47 authored by Bruno Guillaume's avatar Bruno Guillaume

* Remove Rewrite.write_annot (unused code)

parent 84bd1cdf
......@@ -199,13 +199,6 @@ module G_fs = struct
(* ---------------------------------------------------------------------- *)
let get_atom = List_.sort_assoc
(* ---------------------------------------------------------------------- *)
let get_annot_info fs =
match List.filter (fun (fn,_) -> String.length fn > 1 && String.sub fn 0 2 = "__") fs with
| [] -> None
| [(fn,_)] -> Some (String.sub fn 2 ((String.length fn) - 2))
| _ -> Error.build "[Fs.get_annot_info] More than one annot feature in the same feature structure"
(* ---------------------------------------------------------------------- *)
let get_string_atom feat_name t =
match List_.sort_assoc feat_name t with
......
......@@ -49,11 +49,6 @@ module G_fs: sig
val to_dep: ?decorated_feat:(string * string list) -> ?position:float -> ?main_feat: string -> ?filter: string list -> t -> string
val to_conll: ?exclude: string list -> t -> string
(** [get_annot_info fs] searches for a feature with name starting with "__".
It returns the feature_name without the prefix "__"
raise an [Build] exception if there is more than one such feature. *)
val get_annot_info: t -> string option
val to_string: t -> string
val build: ?domain:Domain.t -> Ast.feature list -> t
......
......@@ -296,19 +296,6 @@ module G_graph = struct
let node = Gid_map.find node_id graph.map in
Massoc_gid.exists (fun _ e -> Label_cst.match_ ?domain label_cst e) (G_node.get_next node)
let get_annot_info graph = failwith "Unused function !"
(* let annot_info =
Gid_map.fold
(fun _ node acc ->
match (G_node.get_annot_info node, acc) with
| (None,_) -> acc
| (Some f, None) -> Some (f,G_node.get_position node)
| (Some _, Some _) -> Error.build "[G_node.get_annot_info] Two nodes with annot info"
) graph.map None in
match annot_info with
| Some x -> x
| None -> Error.build "[G_node.get_annot_info] No nodes with annot info" *)
(* -------------------------------------------------------------------------------- *)
let map_add_edge_opt map id_src label id_tar =
let node_src =
......
......@@ -97,11 +97,6 @@ module G_graph: sig
(** [edge_out label_domain t id label_cst] returns true iff there is an out-edge from the node [id] with a label compatible with [label_cst] *)
val edge_out: ?domain:Domain.t -> t -> Gid.t -> Label_cst.t -> bool
(** [get_annot_info graph] searches for exactly one node with an annot-feature (with name starting with "__").
It returns the annot-feature name without the prefix "__" together with the position.
raise an [Build] exception if there is not exactly one annot-feature (with name starting with "__") *)
val get_annot_info: t -> (string * float)
(* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *)
(* Build functions *)
(* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *)
......
......@@ -92,21 +92,6 @@ module Rewrite_history = struct
| _ -> Error.run "[save_det_gr] Not a single rewriting"
in loop t
let save_annot ?domain out_dir base_name t =
List.mapi
(fun i alts ->
match alts.good_nf with
| [alt_1; alt_2] ->
let a = sprintf "%s_%d_A" base_name i in
let b = sprintf "%s_%d_B" base_name i in
let hpa = Instance.save_dep_svg ?domain (Filename.concat out_dir a) alt_1.instance in
let hpb = Instance.save_dep_svg ?domain (Filename.concat out_dir b) alt_2.instance in
let (afn,apos) = G_graph.get_annot_info alt_1.instance.Instance.graph
and (bfn,bpos) = G_graph.get_annot_info alt_2.instance.Instance.graph in
(base_name,i,(afn,apos),(bfn,bpos),(hpa,hpb))
| _ -> Error.run "Not two alternatives in an annotation rewriting in %s" base_name
) t.good_nf
let save_det_conll ?domain ?header base t =
let rec loop t =
match t.good_nf with
......
......@@ -42,9 +42,6 @@ module Rewrite_history: sig
t ->
((string * string list) list * string) list
(** [save_annot out_dir base_name t] writes a set of svg_file for an annotation folder. *)
val save_annot: ?domain:Domain.t -> string -> string -> t -> (string * int * (string*float) * (string*float) * (float option * float option)) 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: ?domain:Domain.t -> string -> t -> unit
......
......@@ -1013,128 +1013,3 @@ module Corpus_stat = struct
fprintf out_ch "%s" (Buffer.contents buff);
close_out out_ch
end (* module Stat *)
module Html_annot = struct
let script_lines static_dir = [
"<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js\"></script>";
sprintf "<script type=\"text/JavaScript\" src=\"%s\"></script>" (Filename.concat static_dir "annot.js")
]
let build ?domain ~title static_dir annot_dir bn_rh_list =
let alt_list = List_.flat_map
(fun (base_name, rew_hist) ->
List.mapi
(fun i alt ->
(sprintf "%s_%d" base_name i, alt)
) (Rewrite_history.save_annot ?domain annot_dir base_name rew_hist)
) bn_rh_list in
let db_buff = Buffer.create 32 in
let len = List.length alt_list in
let cpt = ref 0 in
List_.prev_next_iter
(fun ?prev ?next (base_name,(sentid,i,(afn,apos),(bfn,bpos),(hpa,hpb))) ->
incr cpt;
let init_pos = match (hpa,hpb) with
| (Some p, Some q) -> max 0. ((min p q) -. 500.)
| (Some p, None) | (None, Some p) -> max 0. (p -. 500.)
| _ -> 0. in
(* all entries are "skipped" by default *)
bprintf db_buff "N%s\n" base_name;
let a = sprintf "%s_%d_A" sentid i
and b = sprintf "%s_%d_B" sentid i in
let next_php = match next with
| None -> "index.php"
| Some (bn,_) -> bn^".php" in
let buff = Buffer.create 32 in
let wnl fmt = Printf.ksprintf (fun x -> Printf.bprintf buff "%s\n" x) fmt in
let title = sprintf "Annotation Hit: %d/%d (%s)" !cpt len base_name in
wnl "<?php require '%s'; ?>" (Filename.concat static_dir "record_choice.php");
wnl "<?php require '%s'; ?>" (Filename.concat static_dir "annot_utils.php");
html_header ~css_file:(Filename.concat static_dir "annot.css") ~add_lines:(script_lines static_dir) ~title buff;
wnl "<body onload=\"set_view_pos(%g);\">" init_pos;
wnl "<h2>%s</h2>" title;
wnl "<div id=\"top\"><embed src=\"%s.svg\" type=\"image/svg+xml\"/></div>" a;
wnl "<div id=\"bottom\"><embed src=\"%s.svg\" type=\"image/svg+xml\"/></div>" b;
wnl "";
wnl "<div id=\"middle\">";
wnl "<table>";
wnl "<tr>";
wnl "<td><form action=\"index.php\"><input type=\"submit\" value=\"Index\"></form></td>";
wnl "<td>";
wnl "<form action=\"%s\" method=\"post\">" next_php;
wnl "<input type=\"hidden\" name=\"to_log\" value=\"%s#%g#%s\" />" sentid apos afn;
wnl "<input type=\"hidden\" name=\"hit_id\" value=\"%s_%d\" />" sentid i;
wnl "<input type=\"hidden\" name=\"choice\" value=\"U\" />";
wnl "<input type=\"submit\" value=\"Choose Up\" >";
wnl "</form>";
wnl "</td>";
wnl "<td/>"; (* empty upper right *)
wnl "</tr>";
wnl "";
wnl "<tr>";
(match prev with
| Some (bn,_) -> wnl "<td><form action=\"%s.php\"><input type=\"submit\" value=\"<--Prev--\"></form></td>" bn
| None -> wnl "<td> <form> <input type=\"submit\" value=\"<--Prev--\" disabled> </form> </td>";
);
wnl "<td>";
wnl "<form action=\"%s\" method=\"post\">" next_php;
wnl "<input type=\"hidden\" name=\"to_log\" value=\"%s#%g#No_choice\" />" sentid bpos;
wnl "<input type=\"hidden\" name=\"hit_id\" value=\"%s_%d\" />" sentid i;
wnl "<input type=\"hidden\" name=\"choice\" value=\"N\" />";
wnl "<input type=\"submit\" value=\"Don't choose\" >";
wnl "</form>";
wnl "</td>";
(match next with
| Some (bn,_) -> wnl "<td><form action=\"%s.php\"><input type=\"submit\" value=\"--Next-->\"></form></td>" bn
| None -> wnl "<td> <form> <input type=\"submit\" value=\"--Next-->\" disabled> </form> </td>";
);
wnl "</tr>";
wnl "";
wnl "<tr>";
wnl "<td/>"; (* empty lower left *)
wnl "<td>";
wnl "<form action=\"%s\" method=\"post\">" next_php;
wnl "<input type=\"hidden\" name=\"to_log\" value=\"%s#%g#%s\" />" sentid bpos bfn;
wnl "<input type=\"hidden\" name=\"hit_id\" value=\"%s_%d\" />" sentid i;
wnl "<input type=\"hidden\" name=\"choice\" value=\"D\" />";
wnl "<input type=\"submit\" value=\"Choose Down\" >";
wnl "</form>";
wnl "</td>";
wnl "<td/>"; (* empty lower right *)
wnl "</tr>";
wnl "</table>";
wnl "</div>";
wnl "<?php highlight(\"%s_%d\") ?>" sentid i;
wnl "</body>";
wnl "</html>";
let out_ch = open_out (sprintf "%s.php" (Filename.concat annot_dir base_name)) in
fprintf out_ch "%s" (Buffer.contents buff);
close_out out_ch
) alt_list;
let out_ch = open_out (Filename.concat annot_dir "status.db") in
fprintf out_ch "%s" (Buffer.contents db_buff);
close_out out_ch;
(* creation of the file index.php *)
let buff = Buffer.create 32 in
let wnl fmt = Printf.ksprintf (fun x -> Printf.bprintf buff "%s\n" x) fmt in
wnl "<?php require '%s'; ?>" (Filename.concat static_dir "record_choice.php");
wnl "<?php require '%s'; ?>" (Filename.concat static_dir "annot_utils.php");
html_header ~css_file:(Filename.concat static_dir "annot.css") ~add_lines:(script_lines static_dir) ~title buff;
wnl "<h2>%s</h2>" title;
wnl "<?php index_table() ?>";
let out_ch = open_out (Filename.concat annot_dir "index.php") in
fprintf out_ch "%s" (Buffer.contents buff);
close_out out_ch;
()
end (* module Html_annot *)
......@@ -79,8 +79,3 @@ module Corpus_stat: sig
output_dir:string ->
t -> unit
end (* module Corpus_stat *)
(* ================================================================================ *)
module Html_annot: sig
val build: ?domain: Domain.t -> title:string -> string -> string -> (string * Rewrite_history.t) list -> unit
end (* module Html_annot *)
......@@ -79,8 +79,6 @@ module G_node = struct
| [] -> "_"
| list -> String.concat "|" (List.map (fun (f,v) -> sprintf "%s=%s" f v) list)
let get_annot_info t = G_fs.get_annot_info t.fs
let current_index = ref 0
let fresh_index () = decr current_index; !current_index
......
......@@ -79,11 +79,6 @@ module G_node: sig
val position_comp: t -> t -> int
(** [get_annot_info node] searches for a feature with name starting with "__".
It returns the feature_name without the prefix "__"
raise an [Build] exception if there is more than one such feature. *)
val get_annot_info: t -> string option
(* val build_neighbour: t -> t
val build_new: t -> t *)
......
......@@ -336,9 +336,6 @@ module Rewrite = struct
let write_stat filename rew_hist =
handle ~name:"Rewrite.write_stat" (fun () -> Grew_html.Gr_stat.save filename (Grew_html.Gr_stat.from_rew_history rew_hist)) ()
let write_annot ?domain ~title static_dir annot_dir base_name_rew_hist_list =
handle ~name:"Rewrite.write_annot" (fun () -> Grew_html.Html_annot.build ?domain ~title static_dir annot_dir base_name_rew_hist_list) ()
let save_index ~dirname ~base_names =
handle ~name:"Rewrite.save_index" (fun () ->
let out_ch = open_out (Filename.concat dirname "index") in
......
......@@ -199,8 +199,6 @@ module Rewrite: sig
val save_index: dirname:string -> base_names: string array -> unit
val write_annot: ?domain:Domain.t -> title:string -> string -> string -> (string * history) list -> unit
val write_html: ?domain:Domain.t -> ?no_init: bool -> ?out_gr: bool -> ?filter: string list -> ?main_feat: string -> ?dot: bool -> header: string -> ?graph_file: string -> history -> string -> unit
val error_html: ?domain:Domain.t -> ?no_init:bool -> ?main_feat:string -> ?dot: bool -> header: string -> string -> ?init:Graph.t -> string -> 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