Commit dd80a4e1 authored by bguillaum's avatar bguillaum

better html outputs

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@7453 7838e531-6607-4d57-9587-6c381814729c
parent e6f1aa70
......@@ -109,7 +109,7 @@ module Rewrite_history = struct
let title = sprintf "Sentence: %s --- %d Normal form%s" local l (if l>1 then "s" else "") in
let () = Html.enter html_ch ~title ?header prefix in
fprintf html_ch "<b>Input file</b>: <a href=\"%s\">%s</a></h2><br/>\n"
fprintf html_ch "<b>Input file</b>: <a href=\"%s\">%s</a><br/>\n"
graph_file (Filename.basename graph_file);
fprintf html_ch "<b>Input sentence</b>: <font color=\"green\"><i>%s</i></font></p><br/>\n"
......@@ -575,10 +575,10 @@ module Corpus_stat = struct
fprintf out_ch " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
fprintf out_ch "</head>\n";
fprintf out_ch "<h1>%s</h1>\n" title;
fprintf out_ch "<b>Grs file</b>:<a href =\"%s\">%s</a> -- <a href=\"doc/index.html\">Documentation</a><br/>\n" (Filename.basename grs_file) (Filename.basename grs_file);
fprintf out_ch "<b>Input dir</b>: %s<br/>\n" input_dir;
fprintf out_ch "<b>%d Sentences</b><br/>\n<br/>\n" t.num;
fprintf out_ch "<a href=\"sentences.html\">Sentences</a> -- Rewriting stats -- <a href=\"doc/index.html\">GRS documentation</a>\n";
fprintf out_ch "<h1>%s</h1>\n" (Str.global_replace (Str.regexp "#") " " title);
fprintf out_ch "<h2>Rewriting stats</h2>\n";
fprintf out_ch "<center><table cellpadding=3 cellspacing=0 width=95%%>\n";
List.iter
......
......@@ -13,6 +13,8 @@ module Rewrite_history: sig
}
val is_empty: t -> bool
val num_sol: t -> int
val error_html:
?main_feat: string ->
......
......@@ -144,7 +144,10 @@ module Html = struct
wnl "<html>";
wnl " <head>";
wnl " <link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">";
(match title with Some t -> wnl " <title>%s</title>" t | None -> ());
(match title with
| Some t -> wnl " <title>%s</title>" (Str.global_replace (Str.regexp "#") " " t)
| None -> ()
);
wnl " </head>";
wnl " <body>"
......@@ -358,7 +361,7 @@ module Html = struct
let title = sprintf "Grew -- Graph Rewriting System: %s" (Filename.basename file) in
header ~title buff;
wnl " <div class=\"navbar\">&nbsp;<a href=\"../index.html\">Rewriting Stats</a></div>";
wnl "<a href=\"../sentences.html\">Sentences</a> -- <a href=\"../index.html\">Rewriting stats</a> -- GRS documentation";
wnl "<h1>Graph Rewriting System: %s</h1>" (Filename.basename file);
wnl "<center><b>full path</b>: %s</center>" file;
......@@ -434,6 +437,34 @@ module Html = struct
);
close_out page_out_ch;
done;
done;
done
let html_sentences output_dir sentences =
let buff = Buffer.create 32 in
header ~title:"Sentence list" buff;
bprintf buff "Sentences -- <a href=\"index.html\">Rewriting stats</a> -- <a href=\"doc/index.html\">GRS documentation</a>\n";
bprintf buff "<h2>Sentences list</h2>\n";
bprintf buff "<center><table cellpadding=3 cellspacing=0 width=95%>\n";
bprintf buff "<tr><th class=\"first\">Number of normal forms</th><th>Sentence</th></tr>\n";
List.iter
(fun (base_name_opt, amb, sentence) ->
bprintf buff "<tr>\n";
bprintf buff " <td class=\"first_stats\">%d</td>\n" amb;
(match base_name_opt with
| Some base_name -> bprintf buff " <td class=\"stats\"><a href=\"%s.html\">%s</a></td>\n" base_name sentence
| None -> bprintf buff " <td class=\"stats\">%s</td>\n" sentence);
bprintf buff "</tr>\n";
) sentences;
bprintf buff "</table></center>\n";
let out_ch = open_out (Filename.concat output_dir "sentences.html") in
fprintf out_ch "%s" (Buffer.contents buff);
close_out out_ch
end (* module Html *)
......@@ -2,5 +2,7 @@ open Grew_ast
module Html :
sig
val proceed : dep:bool -> string -> string -> Ast.grs -> unit
val proceed: dep:bool -> string -> string -> Ast.grs -> unit
val html_sentences: string -> (string option * int * string) list -> unit
end
......@@ -26,6 +26,8 @@ type rew_history = Rewrite_history.t
let is_empty = Rewrite_history.is_empty
let num_sol = Rewrite_history.num_sol
let empty_grs = Grs.empty
let set_timeout t = Timeout.timeout := t
......@@ -189,6 +191,8 @@ let make_index ~title ~grs_file ~html ~grs ~seq ~input_dir ~output_dir ~base_nam
) init base_names in
Corpus_stat.save_html title grs_file input_dir output_dir corpus_stat
let html_sentences = Html.html_sentences
let get_css_file = Filename.concat DATA_DIR "style.css"
let graph_of_instance instance = instance.Instance.graph
......@@ -23,6 +23,8 @@ val rewrite: gr:Instance.t -> grs:Grs.t -> seq:string -> Rewrite_history.t
val is_empty: Rewrite_history.t -> bool
val num_sol: Rewrite_history.t -> int
(** display a gr with a grs in a rew_display
@param gr the grapth to rewrite
@param grs the graph rewriting system
......@@ -89,6 +91,8 @@ val make_index:
base_names: string list ->
unit
val html_sentences: string -> (string option * int * string) list -> unit
val get_css_file: string
val graph_of_instance: Instance.t -> G_graph.t
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