Commit 90011abf authored by bguillaum's avatar bguillaum

code review for corpus and stats

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@6637 7838e531-6607-4d57-9587-6c381814729c
parent 126a59b9
......@@ -28,7 +28,7 @@ INFO = @INFO@
OCAMLFIND_DIR=`ocamlfind printconf destdir`
VERSION = 0.9.1
VERSION = 0.9.2
cleanup:
rm -rf *.cmo *.cmx *.cmi *.annot *.o *.*~
......
This diff is collapsed.
......@@ -2,6 +2,8 @@ open Utils
open Graph
open Rule
module Rewrite_history: sig
type t = {
instance: Instance.t;
......@@ -12,10 +14,9 @@ module Rewrite_history: sig
val rules: t -> (string * string list) list
val rules_stat: t -> int StringMap.t
IFDEF DEP2PICT THEN
val save_html: ?main_feat:string -> ?init_graph:bool -> ?header:string -> string -> int -> t -> (string*string list) list
val save_html: ?main_feat:string -> ?init_graph:bool -> ?header:string -> string -> t -> unit
ENDIF
end
......@@ -36,3 +37,34 @@ module Grs: sig
(* only externeal strucutre is returned, each edge contains a "dummy" big_step *)
val build_rew_display: t -> string -> Instance.t -> Grew_types.rew_display
end
module Gr_stat: sig
(** the type [gr] stores the stats for the rewriting of one gr file:
map of [mod.rule] to the max usage in applied during a rewriting. *)
type t = int StringMap.t
val from_rew_history: Rewrite_history.t -> t
val save: string -> t -> unit
val load: string -> t
end
module Corpus_stat: sig
type t
val empty: Grs.t -> t
val add_gr_stat: string -> Gr_stat.t -> t -> t
val save_html:
title: string ->
grs_file: string ->
html:bool -> (* if [html] put hlinks on files *)
output_dir:string ->
t -> unit
end
This diff is collapsed.
......@@ -20,8 +20,20 @@ exception Bug of string * (string * int) option
(**/**)
type grs = Grs.t
type gr = Instance.t
type rew_history
(**/**)
val rewrite: gr:gr -> grs:grs -> seq:string -> rew_history
(** display a gr with a grs in a rew_display
@param gr the grapth to rewrite
@param grs the graph rewriting system
@param seq the name of the sequence to apply
@return a structure {b {i easily}} displayable *)
val display: gr:gr -> grs:grs -> seq:string -> rew_display
val write_stat: string -> rew_history -> unit
val empty_grs : grs
(** get a graph rewriting system from a file
......@@ -41,23 +53,23 @@ val empty_gr : gr
*)
val load_gr : string -> gr
(** rewrite a gr with a grs in a rew_display
@param gr the grapth to rewrite
@param grs the graph rewriting system
@param seq the name of the sequence to apply
@return a structure {b {i easily}} displayable *)
val rewrite : gr:gr -> grs:grs -> seq:string -> rew_display
(* OLD val rules_stat: Grs.t -> string -> string -> (string * int) list *)
val rules_stat: string -> Grs.t -> string -> string -> (string * int) list
IFDEF DEP2PICT THEN
val write_html:
?no_init:bool -> ?main_feat:string -> header: string -> rew_history -> string -> unit
val make_index:
title: string ->
grs_file: string ->
html: bool ->
grs: grs ->
output_dir: string ->
base_names: string list ->
unit
val rewrite_to_html_intern :
?no_init:bool -> ?main_feat:string -> string -> Grs.t -> string -> string -> string -> int -> string -> string -> (string * string list) list option
val rewrite_to_html :
?main_feat:string -> string -> string -> string -> bool -> string -> Grs.t -> string -> string -> unit
IFDEF DEP2PICT THEN
val dummy: unit
(* FIXME: build whitout dep2pict *)
ENDIF
val get_css_file: string
......@@ -114,6 +114,8 @@ module Rule = struct
commands: Command.t list;
}
let get_name t = t.name
let build ?domain ?(locals=[||]) rule_ast =
(* (\* DEBUG *\) Printf.printf "==<Rule.build |neg|=%d>==\n%!" (List.length rule_ast.Ast.neg_patterns); *)
......
......@@ -34,6 +34,8 @@ module Instance_set : Set.S with type elt = Instance.t
module Rule : sig
type t
val get_name: t -> string
val build: ?domain:Ast.domain -> ?locals:Label.decl array -> Ast.rule -> t
(* raise Stop if some command fails to apply *)
......
open Log
open Printf
module StringSet = Set.Make (String)
module StringMap = Map.Make (String)
module IntSet = Set.Make (struct type t = int let compare = Pervasives.compare end)
......@@ -73,6 +74,17 @@ module File = struct
let out_ch = open_out name in
fprintf out_ch "%s\n" data;
close_out out_ch
let read file =
let in_ch = open_in file in
let rev_lines = ref [] in
try
while true do
rev_lines := (input_line in_ch) :: !rev_lines
done; assert false
with End_of_file ->
close_in in_ch;
List.rev !rev_lines
end
......
......@@ -9,6 +9,7 @@ module IntMap : sig
end
module StringMap : Map.S with type key = string
module StringSet : Set.S with type elt = string
module Loc: sig
type t = string * int
......@@ -20,6 +21,8 @@ end
module File: sig
val write: string -> string -> unit
val read: string -> string list
end
module Array_: sig
......
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