Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit 748c152b authored by bguillaum's avatar bguillaum
Browse files

small fixes interface & stats

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@6852 7838e531-6607-4d57-9587-6c381814729c
parent 16cbc5a3
...@@ -131,7 +131,7 @@ module G_fs = struct ...@@ -131,7 +131,7 @@ module G_fs = struct
let get_main ?main_feat t = let get_main ?main_feat t =
let main_list = match main_feat with let main_list = match main_feat with
| None -> [] | None -> []
| Some string -> Str.split (Str.regexp "( *; *)\\|#") string in | Some string -> Str.split (Str.regexp "\\( *; *\\)\\|#") string in
let rec loop = function let rec loop = function
| [] -> (None, t) | [] -> (None, t)
......
...@@ -338,7 +338,7 @@ module G_graph = struct ...@@ -338,7 +338,7 @@ module G_graph = struct
(fun node_id node -> (fun node_id node ->
match G_node.merge_key src_gid tar_gid node with match G_node.merge_key src_gid tar_gid node with
| Some n -> n | Some n -> n
| None -> Error.run ~loc "[Graph.shift_edges] create duplicate edge" | None -> Error.run ~loc "[Graph.shift_in] create duplicate edge"
) graph.map ) graph.map
in {graph with map = new_map} in {graph with map = new_map}
...@@ -349,7 +349,7 @@ module G_graph = struct ...@@ -349,7 +349,7 @@ module G_graph = struct
let tar_node = Gid_map.find tar_gid graph.map in let tar_node = Gid_map.find tar_gid graph.map in
if Massoc.mem_key tar_gid (G_node.get_next src_node) if Massoc.mem_key tar_gid (G_node.get_next src_node)
then Error.run ~loc "[Graph.shift_edges] dependency from src to tar"; then Error.run ~loc "[Graph.shift_out] dependency from src to tar";
let new_map = let new_map =
Gid_map.mapi Gid_map.mapi
...@@ -361,7 +361,7 @@ module G_graph = struct ...@@ -361,7 +361,7 @@ module G_graph = struct
then then
match G_node.shift_out src_node tar_node with match G_node.shift_out src_node tar_node with
| Some n -> n | Some n -> n
| None -> Error.run ~loc "[Graph.shift_edges] common successor" | None -> Error.run ~loc "[Graph.shift_out] common successor"
else node (* other nodes don't change *) else node (* other nodes don't change *)
) graph.map ) graph.map
in {graph with map = new_map} in {graph with map = new_map}
......
...@@ -118,8 +118,6 @@ IFDEF DEP2PICT THEN ...@@ -118,8 +118,6 @@ IFDEF DEP2PICT THEN
let id = sprintf "id_%d" (i+1) in 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 applied rules'; } else { document.getElementById('%s').style.display = 'none';; document.getElementById('p_%s').innerHTML = 'Show applied rules'; }\"><b><p id=\"p_%s\">Show applied rules</p></b></a>\n" id id id id id id; *)
fprintf html_ch "<a style=\"cursor:pointer;\"\n"; fprintf html_ch "<a style=\"cursor:pointer;\"\n";
fprintf html_ch " onClick=\"if (document.getElementById('%s').style.display == 'none')\n" id; 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 applied rules'; }\n" id id; fprintf html_ch " { document.getElementById('%s').style.display = 'block'; document.getElementById('p_%s').innerHTML = 'Hide applied rules'; }\n" id id;
...@@ -447,92 +445,97 @@ module Corpus_stat = struct ...@@ -447,92 +445,97 @@ module Corpus_stat = struct
IntMap.add sol (StringSet.add base_name old) t.amb in IntMap.add sol (StringSet.add base_name old) t.amb in
{ t with map = new_map; num = t.num+1; amb=new_amb; } { t with map = new_map; num = t.num+1; amb=new_amb; }
let save_html ~title ~grs_file ~html ~output_dir t =
let ratio nb = (float nb) /. (float t.num) *. 100. in
let out_ch = open_out (Filename.concat output_dir "index.html") in let unfoldable_set out_ch ?(bound=10) html id file_set =
let counter = ref 0 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"))); StringSet.iter
(fun file ->
if !counter = bound
then fprintf out_ch "<div id=\"%s\" style=\"display:none;\">\n" id;
incr counter;
let link = if html then sprintf "<a href=\"%s.html\">%s</a>" file file else file in
fprintf out_ch "%s &nbsp;&nbsp;\n" link
) file_set;
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; if (!counter > bound)
fprintf out_ch "<h1>%s</h1>\n" title; then
fprintf out_ch "<b>Grs file</b>:<a href =\"%s\">%s</a>\n<br/>\n" (Filename.basename grs_file) (Filename.basename grs_file); begin
fprintf out_ch "<b>%d Sentences</b><br/>\n<br/>\n" t.num; fprintf out_ch "</div>\n";
let if_part = sprintf "document.getElementById('%s').style.display = 'block'; document.getElementById('p_%s').innerHTML = '- Show first %d -';" id id bound in
let else_part = sprintf "document.getElementById('%s').style.display = 'none'; document.getElementById('p_%s').innerHTML = '+ Show all +';" id id in
fprintf out_ch " <div>\n";
fprintf out_ch " <a style=\"cursor:pointer;\" onClick=\"if (document.getElementById('%s').style.display == 'none') { %s } else { %s }\">\n" id if_part else_part;
fprintf out_ch " <b><p id=\"p_%s\">+ Show all +</p></b>\n" id;
fprintf out_ch " </a>\n";
fprintf out_ch " </div>\n";
end
fprintf out_ch "<center><table cellpadding=3 cellspacing=0 width=95%%>\n";
List.iter
(fun modul ->
let modul = modul.Modul.name in
let rules = StringMap.find modul t.map in
fprintf out_ch "<tr><td colspan=\"5\" style=\"padding: 0px;\"><h6>Module %s</h6></td></tr>\n" modul;
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
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;
if html
then tmp := sprintf "%s\n <a href=\"%s.html\">%s</a> &nbsp; &nbsp;" !tmp h h
else tmp := sprintf "%s\n %s &nbsp; &nbsp;" !tmp 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;
if html
then tmp := sprintf "%s\n <a href=\"%s.html\">%s</a>&nbsp;&nbsp;" !tmp h h
else tmp := sprintf "%s\n %s&nbsp;&nbsp;" !tmp h
);
compute t
in compute file_list;
if file_list = [] then tmp := "&nbsp;";
let file_num = List.length file_list in
fprintf out_ch "<tr>\n";
fprintf out_ch "<td class=\"first_stats\" valign=top>%s</td>\n" rule; let save_html ~title ~grs_file ~html ~output_dir t =
fprintf out_ch "<td class=\"stats\" valign=top>%d</td>\n" occ_num; (* a fucntion to get the ration wrt the full set [t] *)
fprintf out_ch "<td class=\"stats\" valign=top>%d</td>\n" file_num; let ratio nb = (float nb) /. (float t.num) *. 100. in
fprintf out_ch "<td class=\"stats\" valign=top>%.2f%%</td>\n" (ratio file_num);
(* put the css file the [output_dir] *)
fprintf out_ch "<td class=\"stats\">%s" !tmp; ignore(Sys.command("cp "^(Filename.concat DATA_DIR "style.css")^" "^(Filename.concat output_dir "style.css")));
if (!counter > 10)
then ( (* output of index.html *)
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 all +</p></b></a>\n" let out_ch = open_out (Filename.concat output_dir "index.html") in
modul rule
(sprintf "document.getElementById('%s_%s').style.display = 'block'; document.getElementById('p_%s_%s').innerHTML = '- Show first ten -';" modul rule modul rule) fprintf out_ch "<head>\n";
(sprintf "document.getElementById('%s_%s').style.display = 'none';; document.getElementById('p_%s_%s').innerHTML = '+ Show all +';" modul rule modul rule) fprintf out_ch " <link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">\n";
modul rule; fprintf out_ch " <title>%s</title>\n" title;
); fprintf out_ch " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
fprintf out_ch "</td></tr>\n"; fprintf out_ch "</head>\n";
) rules;
) t.modules; fprintf out_ch "<h1>%s</h1>\n" title;
fprintf out_ch "<b>Grs file</b>:<a href =\"%s\">%s</a>\n<br/>\n" (Filename.basename 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=3 cellspacing=0 width=95%%>\n";
List.iter
(fun modul ->
let modul = modul.Modul.name in
let rules = StringMap.find modul t.map in
fprintf out_ch "<tr><td colspan=\"5\" style=\"padding: 0px;\"><h6>Module %s</h6></td></tr>\n" modul;
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 id = sprintf "%s_%s" modul rule in
let file_num = StringSet.cardinal file_set in
fprintf out_ch "<tr>\n";
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\">\n";
(if file_num = 0
then fprintf out_ch " &nbsp;"
else unfoldable_set out_ch html id file_set);
fprintf out_ch " </td>\n";
fprintf out_ch "</tr>\n";
) rules;
) t.modules;
(* add a subtlabe for sentence ambiguity *) (* add a subtlabe for sentence ambiguity *)
...@@ -544,22 +547,24 @@ module Corpus_stat = struct ...@@ -544,22 +547,24 @@ module Corpus_stat = struct
IntMap.iter IntMap.iter
(fun num set -> (fun num set ->
let id = sprintf "amb_%d" num in
let num_files = StringSet.cardinal set in let num_files = StringSet.cardinal set in
fprintf out_ch "<tr>\n"; fprintf out_ch "<tr>\n";
fprintf out_ch "<td class=\"first_stats\">%d</td>\n" num; fprintf out_ch " <td class=\"first_stats\">%d</td>\n" num;
fprintf out_ch "<td class=\"stats\" colspan=2>%d</td>\n" num_files; fprintf out_ch " <td class=\"stats\" colspan=2>%d</td>\n" num_files;
fprintf out_ch "<td class=\"stats\">%.2f%%</td>\n" (ratio num_files); fprintf out_ch " <td class=\"stats\">%.2f%%</td>\n" (ratio num_files);
fprintf out_ch "<td class=\"stats\">"; fprintf out_ch " <td class=\"stats\">";
StringSet.iter (* StringSet.iter *)
(fun (file) -> (* (fun (file) -> *)
if html (* if html *)
then fprintf out_ch "<a href=\"%s.html\">%s</a><br/>" file file (* then fprintf out_ch "<a href=\"%s.html\">%s</a><br/>" file file *)
else fprintf out_ch "%s<br/>" file (* else fprintf out_ch "%s<br/>" file *)
) set; (* ) set; *)
unfoldable_set out_ch html id set;
fprintf out_ch "</td>\n";
fprintf out_ch "</tr>") t.amb fprintf out_ch " </td>\n";
fprintf out_ch "</tr>\n") t.amb
end; end;
......
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