Commit f0981b5a authored by bguillaum's avatar bguillaum

improve stat html page (total for module)

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@6656 7838e531-6607-4d57-9587-6c381814729c
parent dee9748e
......@@ -85,6 +85,30 @@ td.first_stats {
border-left-style:dotted;
border-left-color:black;
}
td.total {
background-color: #DDDDDD;
border-right-width: 1px; r
border-right-style:dotted;
border-right-color:black;
border-bottom-width: 1px;
border-bottom-style:dotted;
border-bottom-color:black;
}
td.first_total {
background-color: #DDDDDD;
border-right-width: 1px;
border-right-style:dotted;
border-right-color:black;
border-bottom-width: 1px;
border-bottom-style:dotted;
border-bottom-color:black;
border-left-width: 1px;
border-left-style:dotted;
border-left-color:black;
}
td.typefieldcomment { background-color : #FFFFFF }
pre { margin-bottom: 4px }
div.sig_block {margin-left: 2em}
......@@ -17,49 +17,29 @@ module Rewrite_history = struct
bad_nf: Instance.t list;
}
let rec get_nfs t =
match t.good_nf with
| [] -> [([], t.instance)]
| l ->
List.flatten
(List_.mapi
(fun i t' ->
List.map
(fun (path,x) -> (i::path,x))
(get_nfs t')
) l
)
let rec rules t =
let local = (t.module_name, t.instance.Instance.rules) in
match t.good_nf with
| [] -> [local]
| l -> local :: (List.flatten (List.map rules l))
IFDEF DEP2PICT THEN
(* warning: path are returned in reverse order *)
let save_all_dep ?main_feat base_name t =
let nfs = ref [] in
let rec loop first (rev_path, rev_rules) t =
let file =
match List.rev rev_path with
| [] -> base_name
| l -> sprintf "%s_%s" base_name (List_.to_string string_of_int "_" l) in
(** [save_nfs ?main_feat base_name t] does two things:
- write PNG files of normal forms
- returns a list of couples (rules, file)
*)
let save_nfs ?main_feat base_name t =
let rec loop file_name rules t =
match t.good_nf with
| [] -> (* t is a leaf of the tree history *)
Instance.save_dep_png ?main_feat file t.instance;
nfs := (rev_path,List.rev rev_rules,file) :: !nfs
| l ->
List_.iteri
(fun i t' ->
loop false (i::rev_path,(t.module_name, t'.instance.Instance.rules)::rev_rules) t'
) l in
loop true ([],[]) t;
List.rev !nfs
| [] -> Instance.save_dep_png ?main_feat file_name t.instance; [rules, file_name]
| l ->
List_.foldi_left
(fun i acc son ->
(* Instance.save_dep_png ?main_feat (sprintf "%s_%d" file_name i) son.instance; *)
let nfs = loop
(sprintf "%s_%d" file_name i)
(rules @ [t.module_name, son.instance.Instance.rules])
son in
nfs @ acc
)
[] l
in loop base_name [] t
let error_html ?main_feat ?(init_graph=true) ?header prefix msg inst_opt =
(* remove files from previous runs *)
let _ = Unix.system (sprintf "rm -f %s*.html" prefix) in
......@@ -96,7 +76,7 @@ IFDEF DEP2PICT THEN
(if init_graph then Instance.save_dep_png ?main_feat prefix t.instance);
let nf_files = save_all_dep ?main_feat prefix t in
let nf_files = save_nfs ?main_feat prefix t in
let l = List.length nf_files in
......@@ -116,7 +96,7 @@ IFDEF DEP2PICT THEN
end;
List_.iteri
(fun i (_,rules_list,file_name) ->
(fun i (rules_list,file_name) ->
fprintf html_ch "<h6>Solution %d</h6>\n" (i+1);
let local_name = Filename.basename file_name in
......@@ -129,7 +109,14 @@ IFDEF DEP2PICT THEN
let id = sprintf "id_%d" (i+1) in
fprintf html_ch "<a style=\"cursor:pointer;\" onClick=\"if (document.getElementById('%s').style.display == 'none') { document.getElementById('%s').style.display = 'block'; document.getElementById('p_%s').innerHTML = 'Hide'; } else { document.getElementById('%s').style.display = 'none';; document.getElementById('p_%s').innerHTML = 'Show'; }\"><b><p id=\"p_%s\">Show</p></b></a>\n" id id id id id id;
(* fprintf html_ch "<a style=\"cursor:pointer;\" onClick=\"if (document.getElementById('%s').style.display == 'none') { document.getElementById('%s').style.display = 'block'; document.getElementById('p_%s').innerHTML = 'Hide'; } else { document.getElementById('%s').style.display = 'none';; document.getElementById('p_%s').innerHTML = 'Show'; }\"><b><p id=\"p_%s\">Show</p></b></a>\n" id id id id id id; *)
fprintf html_ch "<a style=\"cursor:pointer;\"\n";
fprintf html_ch " onClick=\"if (document.getElementById('%s').style.display == 'none')\n" id;
fprintf html_ch " { document.getElementById('%s').style.display = 'block'; document.getElementById('p_%s').innerHTML = 'Hide'; }\n" id id;
fprintf html_ch " else { document.getElementById('%s').style.display = 'none';; document.getElementById('p_%s').innerHTML = 'Show'; }\">" id id;
fprintf html_ch " <b><p id=\"p_%s\">Show</p></b>\n" id;
fprintf html_ch "</a>\n";
fprintf html_ch " <div id=\"%s\" style=\"display:none;\">\n" id;
......@@ -384,11 +371,24 @@ module Corpus_stat = struct
fprintf out_ch "<b>Grs file</b>:<a href =\"%s\">%s</a>\n<br/>\n" grs_file (Filename.basename grs_file);
fprintf out_ch "<b>%d Sentences</b><br/>\n<br/>\n" t.num;
fprintf out_ch "<center><table cellpadding=10 cellspacing=0 width=90%%>\n";
fprintf out_ch "<center><table cellpadding=3 cellspacing=0 width=95%%>\n";
StringMap.iter
(fun modul rules ->
fprintf out_ch "<tr><td colspan=\"5\" style=\"padding: 0px;\"><h6>Module %s</h6></td>\n" modul;
fprintf out_ch "<tr><th class=\"first\" width=10>Rule</th><th width=10>#occ</th><th width=10>#files</th><th width=10>Ratio</th><th width=10>Files</th></tr>\n";
fprintf out_ch "<tr><th class=\"first\">Rule</th><th>#occ</th><th>#files</th><th>Ratio</th><th>Files</th></tr>\n";
let (tot_occ, full_sent) =
StringMap.fold
(fun _ (occ_num, file_set) (acc_occ, acc_sent) -> (acc_occ + occ_num, StringSet.union acc_sent file_set))
rules (0,StringSet.empty) in
let tot_sent = StringSet.cardinal full_sent in
fprintf out_ch "<tr>\n";
fprintf out_ch "<td class=\"first_total\">Total for module</td>\n";
fprintf out_ch "<td class=\"total\">%d</td>" tot_occ;
fprintf out_ch "<td class=\"total\">%d</td>" tot_sent;
fprintf out_ch "<td class=\"total\">%.2f%%</td>" (ratio tot_sent);
fprintf out_ch "<td class=\"total\">&nbsp;</td>\n";
fprintf out_ch "</tr>\n";
StringMap.iter
(fun rule (occ_num, file_set) ->
let file_list = StringSet.elements file_set in
......@@ -403,8 +403,8 @@ module Corpus_stat = struct
);
incr counter;
if html
then tmp := sprintf "%s<a href=\"%s.html\">%s</a>" !tmp h h
else tmp := sprintf "%s%s" !tmp h
then tmp := sprintf "%s&nbsp;&nbsp;<a href=\"%s.html\">%s</a>" !tmp h h
else tmp := sprintf "%s&nbsp;&nbsp;%s" !tmp h
| h::t ->
if (not (List.mem h t)) then ( (*avoid doublons*)
if (!counter = 10) then (
......@@ -412,8 +412,8 @@ module Corpus_stat = struct
);
incr counter;
if html
then tmp := sprintf "%s<a href=\"%s.html\">%s</a>" !tmp h h
else tmp := sprintf "%s%s" !tmp h
then tmp := sprintf "&nbsp;&nbsp;<a href=\"%s.html\">%s</a>%s" h h !tmp
else tmp := sprintf "%s&nbsp;&nbsp;%s" !tmp h
);
compute t
in compute (List.rev file_list);
......@@ -423,10 +423,10 @@ module Corpus_stat = struct
let file_num = List.length file_list in
fprintf out_ch "<tr>\n";
fprintf out_ch "<td class=\"first_stats\" width=10 valign=top>%s</td>\n" rule;
fprintf out_ch "<td class=\"stats\" width=10 valign=top>%d</td>\n" occ_num;
fprintf out_ch "<td class=\"stats\" width=10 valign=top>%d</td>\n" file_num;
fprintf out_ch "<td class=\"stats\" width=10 valign=top>%.2f%%</td>\n" (ratio file_num);
fprintf out_ch "<td class=\"first_stats\" valign=top>%s</td>\n" rule;
fprintf out_ch "<td class=\"stats\" valign=top>%d</td>\n" occ_num;
fprintf out_ch "<td class=\"stats\" valign=top>%d</td>\n" file_num;
fprintf out_ch "<td class=\"stats\" valign=top>%.2f%%</td>\n" (ratio file_num);
fprintf out_ch "<td class=\"stats\">%s" !tmp;
if (!counter > 10)
......@@ -445,32 +445,30 @@ module Corpus_stat = struct
(* add a subtlabe for sentence that produces an error *)
let nb_errors = List.length t.error in
fprintf out_ch "<tr><td colspan=5><h6>ERRORS</h6></td>\n";
fprintf out_ch "<tr><th class=\"first\" width=10>Rule</th><th colspan=2 width=20>#files</th><th width=10>Ratio</th><th>Files</th></tr>\n";
fprintf out_ch "<tr><th class=\"first\" >Rule</th><th colspan=2 width=20>#files</th><th >Ratio</th><th>Files</th></tr>\n";
fprintf out_ch "<tr>\n";
fprintf out_ch "<td class=\"first_stats\">Errors</td>\n";
fprintf out_ch "<td class=\"stats\" colspan=2>%d</td>\n" nb_errors;
fprintf out_ch "<td class=\"stats\">%.2f%%</td>\n" (ratio nb_errors);
fprintf out_ch "<td class=\"stats\">";
List.iter
(fun (file,err) ->
if html
then
fprintf out_ch "<a href=\"%s.html\">%s</a>: %s<br/>"
file
file
err
else
fprintf out_ch "%s: %s<br/>" file
err
) (List.rev t.error);
fprintf out_ch "</td>\n";
fprintf out_ch "</tr>";
fprintf out_ch "</table></center>\n";
close_out out_ch;
()
match t.error with
| [] -> fprintf out_ch "&nbsp;"
| l ->
List.iter
(fun (file,err) ->
if html
then fprintf out_ch "<a href=\"%s.html\">%s</a>: %s<br/>" file file err
else fprintf out_ch "%s: %s<br/>" file err
) (List.rev l);
fprintf out_ch "</td>\n";
fprintf out_ch "</tr>";
fprintf out_ch "</table></center>\n";
close_out out_ch;
()
end (* module Stat *)
......@@ -12,15 +12,11 @@ module Rewrite_history: sig
bad_nf: Instance.t list;
}
val rules: t -> (string * string list) list
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 -> string -> t -> unit
ENDIF
ENDIF
end
......
......@@ -65,8 +65,7 @@ let load_gr file =
)
let rewrite ~gr ~grs ~seq =
try
Grs.rewrite grs seq gr
try Grs.rewrite grs seq gr
with
| Utils.Run (msg,loc) -> raise (Run (msg,loc))
| Utils.Bug (msg, loc) -> raise (Bug (msg,loc))
......@@ -74,8 +73,7 @@ let rewrite ~gr ~grs ~seq =
let display ~gr ~grs ~seq =
try
Grs.build_rew_display grs seq gr
try Grs.build_rew_display grs seq gr
with
| Utils.Run (msg,loc) -> raise (Run (msg,loc))
| Utils.Bug (msg, loc) -> raise (Bug (msg,loc))
......@@ -84,29 +82,12 @@ let display ~gr ~grs ~seq =
let write_stat filename rew_hist = Gr_stat.save filename (Gr_stat.from_rew_history rew_hist)
(* let rules_stat grs seq gr_file = *)
(* try *)
(* let gr = Instance.build (Grew_parser.parse_file_to_gr gr_file) in *)
(* let rew_hist = Grs.rewrite grs seq gr in *)
(* StringMap.fold *)
(* (fun key value acc -> *)
(* (key,value)::acc *)
(* ) *)
(* (Gr_stat.from_rew_history rew_hist) *)
(* [] *)
(* with *)
(* | Utils.Run (msg, Some (loc_file,loc_line)) -> *)
(* Log.fmessage "[file: %s, line: %d] Utils.run: %s\n" loc_file loc_line msg; [] *)
(* | exc -> *)
(* Log.fmessage "Unexpected exception: %s\n" (Printexc.to_string exc); [] *)
let write_html
?(no_init=false) ?main_feat
~header
rew_hist
output_base =
IFDEF DEP2PICT THEN
ignore (
Rewrite_history.save_html
?main_feat
......@@ -114,12 +95,16 @@ let write_html
~header
output_base rew_hist
)
ELSE
Log.critical "[write_html] The \"libcaml-grew\" library is compiled without Dep2pict"
ENDIF
let error_html
?(no_init=false) ?main_feat
~header
msg ?init
output_base =
IFDEF DEP2PICT THEN
ignore (
Rewrite_history.error_html
?main_feat
......@@ -127,224 +112,11 @@ let error_html
~header
output_base msg init
)
ELSE
Log.critical "[_html] The \"libcaml-grew\" library is compiled without Dep2pict"
ENDIF
IFDEF DEP2PICT THEN
let dummy = ()
(* let rewrite_to_html_intern *)
(* ?(no_init=false) *)
(* ?main_feat *)
(* grs_file *)
(* grs seq *)
(* gr_file *)
(* output_base *)
(* nb_sentence *)
(* previous *)
(* next = *)
(* let header = "" in *)
(* let _ = *)
(* Sys.command (sprintf "cp %s %s" *)
(* gr_file *)
(* (Filename.concat (Filename.dirname output_base) (Filename.basename gr_file)) *)
(* ) in *)
(* try *)
(* let init = Instance.build (Grew_parser.parse_file_to_gr gr_file) in *)
(* try *)
(* let rew_hist = Grs.rewrite grs seq init in *)
(* ignore ( (\* FIXME: ingore inutile *\) *)
(* Rewrite_history.save_html *)
(* ?main_feat *)
(* ~init_graph: (not no_init) *)
(* ~header *)
(* output_base rew_hist *)
(* ) *)
(* with *)
(* | Utils.Run (msg, Some (loc_file,loc_line)) -> *)
(* let html_ch = open_out (sprintf "%s.html" output_base) in *)
(* Html.enter html_ch ~header output_base; *)
(* fprintf html_ch "<h6>Initial graph</h6>\n"; *)
(* Instance.save_dep_png ?main_feat output_base init; *)
(* fprintf html_ch "<div width=100%% style=\"overflow-x:auto\"><IMG SRC=\"%s.png\"></div>\n" (Filename.basename output_base); *)
(* fprintf html_ch "<h2>ERROR during rewriting:</h2>\n"; *)
(* fprintf html_ch "<p>Message: %s</p>\n" msg; *)
(* fprintf html_ch "<p>File: %s</p>\n" loc_file; *)
(* fprintf html_ch "<p>Line: %d</p>\n" loc_line; *)
(* Html.leave html_ch; *)
(* close_out html_ch with *)
(* | exc -> *)
(* let html_ch = open_out (sprintf "%s.html" output_base) in *)
(* Html.enter html_ch ~header output_base; *)
(* fprintf html_ch "<h1>UNEXPECTED EXCEPTION: %s</h1>" (Printexc.to_string exc); *)
(* Html.leave html_ch; *)
(* close_out html_ch *)
(* let rewrite_to_html ?main_feat input_dir output_dir no_init grs_file grs seq title = *)
(* try *)
(* (\* get ALL gr files *\) *)
(* let all_files = Array.to_list (Sys.readdir input_dir) in *)
(* let gr_files = List.sort (fun a b -> compare a b) *)
(* (List.filter (fun file -> Filename.check_suffix file ".gr") all_files) in *)
(* let nb_files = List.length gr_files in *)
(* let ratio nb = (float nb) /. (float nb_files) *. 100. in *)
(* (\* create html files *\) *)
(* ignore (Sys.command (sprintf "cp %s %s" grs_file *)
(* (Filename.concat output_dir (Filename.basename grs_file)))); *)
(* let sentence_counter = ref 1 in *)
(* List.iter *)
(* (fun input -> *)
(* Log.fmessage "Computing %s" input; *)
(* let rules = rewrite_to_html_intern *)
(* ~no_init *)
(* grs_file *)
(* grs *)
(* seq *)
(* (Filename.concat input_dir input) *)
(* (Filename.concat output_dir (Filename.chop_extension input)) *)
(* ?main_feat *)
(* !sentence_counter *)
(* (if !sentence_counter > 1 then (Filename.chop_extension (List.nth gr_files (!sentence_counter-2))) else "") *)
(* (if !sentence_counter < nb_files then (Filename.chop_extension (List.nth gr_files (!sentence_counter))) else "") *)
(* in *)
(* incr sentence_counter; *)
(* (\* match rules with *\) *)
(* (\* | Some module_list -> *\) *)
(* (\* List.iter *\) *)
(* (\* (fun (module_name, rule_list) -> *\) *)
(* (\* List.iter *\) *)
(* (\* (fun rule -> *\) *)
(* (\* stats := Corpus_stat.add module_name rule input 1 !stats *\) *)
(* (\* ) rule_list *\) *)
(* (\* (\\* let old_rule_list = *\\) *\) *)
(* (\* (\\* try ref (StringMap.find module_name !stats) *\\) *\) *)
(* (\* (\\* with Not_found -> ref StringMap.empty in *\\) *\) *)
(* (\* (\\* List.iter *\\) *\) *)
(* (\* (\\* (fun rule -> *\\) *\) *)
(* (\* (\\* let old = try StringMap.find rule !old_rule_list with Not_found -> [] in *\\) *\) *)
(* (\* (\\* old_rule_list := StringMap.add rule (input::old) !old_rule_list *\\) *\) *)
(* (\* (\\* ) rule_list; *\\) *\) *)
(* (\* (\\* stats := StringMap.add module_name !old_rule_list !stats *\\) *\) *)
(* (\* ) module_list *\) *)
(* (\* | None -> errors := input :: !errors *\) *)
(* ) gr_files; *)
(* (\* let out_ch = open_out (Filename.concat output_dir "index.html") in *\) *)
(* (\* let css = "<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">" in *\) *)
(* (\* ignore(Sys.command("cp "^(Filename.concat DATA_DIR "style.css")^" "^(Filename.concat output_dir "style.css"))); *\) *)
(* (\* fprintf out_ch "<head>\n%s\n<title>%s</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head>\n" css title; *\) *)
(* (\* fprintf out_ch "<h1>%s</h1>\n" title; *\) *)
(* (\* fprintf out_ch "<b>Grs file</b>:%s\n<br/>\n" (Filename.basename grs_file); *\) *)
(* (\* fprintf out_ch "<b>%d Sentences</b><br/>\n<br/>\n" nb_files; *\) *)
(* (\* fprintf out_ch "<center><table cellpadding=10 cellspacing=0 width=90%%>\n"; *\) *)
(* (\* StringMap.iter *\) *)
(* (\* (fun modul rules -> *\) *)
(* (\* fprintf out_ch "<tr><td colspan=5><h6>Module %s</h6></td>\n" modul; *\) *)
(* (\* fprintf out_ch "<tr><th class=\"first\" width=10>Rule</th><th width=10>#occ</th><th width=10>#files</th><th width=10>Ratio</th><th width=10>Files</th></tr>\n"; *\) *)
(* (\* StringMap.iter *\) *)
(* (\* (fun rule (occ_num, file_set) -> *\) *)
(* (\* let file_list = StringSet.elements file_set in *\) *)
(* (\* let tmp = ref "" in *\) *)
(* (\* let counter = ref 0 in *\) *)
(* (\* let rec compute list = match list with *\) *)
(* (\* | [] -> () *\) *)
(* (\* | h::[] -> *\) *)
(* (\* if (!counter = 10) then ( *\) *)
(* (\* tmp := sprintf "%s<div id=\"%s_%s\" style=\"display:none;\">\n" !tmp modul rule *\) *)
(* (\* ); *\) *)
(* (\* incr counter; *\) *)
(* (\* tmp := sprintf "%s<a href=\"%s\">%s</a>" !tmp ((Filename.chop_extension h)^".html") (Filename.chop_extension h) *\) *)
(* (\* | h::t -> *\) *)
(* (\* if (not (List.mem h t)) then ( (\\*avoid doublons*\\) *\) *)
(* (\* if (!counter = 10) then ( *\) *)
(* (\* tmp := sprintf "%s<div id=\"%s_%s\" style=\"display:none;\">\n" !tmp modul rule *\) *)
(* (\* ); *\) *)
(* (\* incr counter; *\) *)
(* (\* tmp := sprintf "%s<a href=\"%s\">%s</a><br/>" !tmp ((Filename.chop_extension h)^".html") (Filename.chop_extension h) *\) *)
(* (\* ); *\) *)
(* (\* compute t *\) *)
(* (\* in compute (List.rev file_list); *\) *)
(* (\* let file_num = List.length file_list in *\) *)
(* (\* fprintf out_ch "<tr>\n"; *\) *)
(* (\* fprintf out_ch "<td class=\"first_stats\" width=10 valign=top>%s</td>\n" rule; *\) *)
(* (\* fprintf out_ch "<td class=\"stats\" width=10 valign=top>%d</td>\n" occ_num; *\) *)
(* (\* fprintf out_ch "<td class=\"stats\" width=10 valign=top>%d</td>\n" file_num; *\) *)
(* (\* fprintf out_ch "<td class=\"stats\" width=10 valign=top>%.2f%%</td>\n" (ratio file_num); *\) *)
(* (\* fprintf out_ch "<td class=\"stats\">%s" !tmp; *\) *)
(* (\* if (!counter > 10) *\) *)
(* (\* then ( *\) *)
(* (\* fprintf out_ch "</div><a style=\"cursor:pointer;\" onClick=\"if (document.getElementById('%s_%s').style.display == 'none') { %s } else { %s }\"><b><p id=\"p_%s_%s\">+ Show more +</p></b></a>\n" *\) *)
(* (\* modul rule *\) *)
(* (\* (sprintf "document.getElementById('%s_%s').style.display = 'block'; document.getElementById('p_%s_%s').innerHTML = '- Show less -';" modul rule modul rule) *\) *)
(* (\* (sprintf "document.getElementById('%s_%s').style.display = 'none';; document.getElementById('p_%s_%s').innerHTML = '+ Show more +';" modul rule modul rule) *\) *)
(* (\* modul rule; *\) *)
(* (\* ); *\) *)
(* (\* fprintf out_ch "</td></tr>\n"; *\) *)
(* (\* ) rules; *\) *)
(* (\* ) !stats; *\) *)
(* (\* (\\* add a subtalbe for sentence that produces an error *\\) *\) *)
(* (\* let nb_errors = List.length !errors in *\) *)
(* (\* fprintf out_ch "<tr><td colspan=5><h6>ERRORS</h6></td>\n"; *\) *)
(* (\* fprintf out_ch "<tr><th class=\"first\" width=10>Rule</th><th colspan=2 width=20>#files</th><th width=10>Ratio</th><th>Files</th></tr>\n"; *\) *)
(* (\* fprintf out_ch "<tr>\n"; *\) *)
(* (\* fprintf out_ch "<td class=\"first_stats\">Errors</td>\n"; *\) *)
(* (\* fprintf out_ch "<td class=\"stats\" colspan=2>%d</td>\n" nb_errors; *\) *)
(* (\* fprintf out_ch "<td class=\"stats\">%.2f%%</td>\n" (ratio nb_errors); *\) *)
(* (\* fprintf out_ch "<td class=\"stats\">"; *\) *)
(* (\* List.iter *\) *)
(* (\* (fun err -> *\) *)
(* (\* fprintf out_ch "<a href=\"%s.html\">%s</a><br/>" (Filename.chop_extension err) (Filename.chop_extension err) *\) *)
(* (\* ) (List.rev !errors); *\) *)
(* (\* fprintf out_ch "</td>\n"; *\) *)
(* (\* fprintf out_ch "</tr>"; *\) *)
(* (\* fprintf out_ch "</table></center>\n"; *\) *)
(* (\* close_out out_ch; *\) *)
(* (\* () *\) *)
(* with *)
(* | Utils.Run (msg,loc) -> raise (Run (msg,loc)) *)
(* | Utils.Bug (msg, loc) -> raise (Bug (msg,loc)) *)
(* | exc -> raise (Bug (sprintf "UNCATCHED EXCEPTION: %s" (Printexc.to_string exc), None)) *)
ENDIF
(* (\* read all stats in [dir] and produce an html file with full stats *\) *)
(* let collect_stats init dir = *)
(* let all_files = Array.to_list (Sys.readdir dir) in *)
(* let stat_files = List.filter (fun f -> Filename.check_suffix f ".stat") all_files in *)
(* List.fold_left *)
(* (fun acc stat_file -> *)
(* List.fold_left *)
(* (fun acc2 line -> *)
(* match Str.split (Str.regexp "\\.\\|:") line with *)
(* | [modul; rule; num] -> (\* FIXME *\) acc2 *)
(* | _ -> Log.fcritical "invalid stat line: %s" line *)
(* ) acc (File.read stat_file) *)
(* ) init stat_files *)
let make_index ~title ~grs_file ~html ~grs ~output_dir ~base_names =
let init = Corpus_stat.empty grs in
......
(* include Grew_types *)
(** {2 Grew's core} *)
open Utils
......@@ -53,8 +53,6 @@ val empty_gr : gr
*)
val load_gr : string -> gr
(* OLD val rules_stat: Grs.t -> string -> string -> (string * int) list *)
val write_html:
?no_init:bool -> ?main_feat:string -> header: string -> rew_history -> string -> unit
......@@ -70,9 +68,4 @@ val make_index:
base_names: string list ->
unit
IFDEF DEP2PICT THEN
val dummy: unit
(* FIXME: build whitout dep2pict *)
ENDIF
val get_css_file: string
......@@ -44,7 +44,7 @@ module Instance = struct
IFDEF DEP2PICT THEN
let save_dep_png ?main_feat base t =
ignore (Dep2pict.fromDepStringToPng (Graph.to_dep ?main_feat t.graph) (base^".png"))
ignore (Dep2pict.fromDepStringToPng (Graph.to_dep ?main_feat t.graph) (base^".png"))
ENDIF
end
......
......@@ -36,7 +36,7 @@ module IntMap =
(*
* union of two injective maps having different ranges :
* \forall x \neq y \in m: m(x) \neq m(y)
* \forall x' \neq y' \in m': m'(x) \neq m'(y)
* \forall x' \neq y' \in m': m'(x) \neq m'(y)W
* \forall x \in m /\ m': m(x) = m'(x)
* \forall x \in m : x \not\in\m' => \forall y \in m' m(x) \neq m'(y)
*)
......@@ -257,6 +257,12 @@ module List_ = struct
| x1::t1, x2::t2 -> loop (t1, t2) in
loop (l1,l2)
let foldi_left f init l =
fst
(List.fold_left
(fun (acc,i) elt -> (f i acc elt, i+1))
(init,0) l
)
end
......
......@@ -68,6 +68,7 @@ module List_: sig
val sort_included_diff: 'a list -> 'a list -> 'a list
val sort_diff: 'a list -> 'a list -> 'a list
val foldi_left: (int -> 'a -> 'b -> 'a) -> 'a -> 'b list -> 'a
end
(* module Massoc implements multi-association data: keys are int and the same key can be
......
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