Commit f6b78841 authored by bguillaum's avatar bguillaum

add function "to_sentence"

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@7199 7838e531-6607-4d57-9587-6c381814729c
parent b90bd7ce
......@@ -491,6 +491,8 @@ module G_graph = struct
)
(String.concat " " words)
[
" -t-", "-t-";
"_-_", "-";
"_", " ";
"' ", "'";
" ,", ",";
......
......@@ -11,7 +11,7 @@ module IntMap = Map.Make (struct type t = int let compare = Pervasives.compare e
module Loc = struct
type t = string * int
let to_string (file,line) = Printf.sprintf "(file: %s, line: %d)" (Filename.basename file) line
let to_string (file,line) = sprintf "(file: %s, line: %d)" (Filename.basename file) line
let opt_set_line line = function
| None -> None
......@@ -43,6 +43,7 @@ module File = struct
close_in in_ch;
List.rev !rev_lines
(* [read_ln file] returns a list of couples (line_num, line). Blank lines and lines starting with '%' are ignored. *)
let read_ln file =
let in_ch = open_in file in
let cpt = ref 0 in
......@@ -60,15 +61,12 @@ module File = struct
List.rev !rev_lines
end (* module File *)
(* ================================================================================ *)
module Pid = struct
type t = int
let compare = Pervasives.compare
end (* module Pid *)
(* ================================================================================ *)
module Pid_map =
struct
......@@ -132,8 +130,6 @@ end
module Gid_map = Map.Make (Gid)
(* ================================================================================ *)
module Array_ = struct
let dicho_mem elt array =
let rec loop low high =
......
......@@ -25,8 +25,7 @@ module File: sig
(** [read file_name] read the content of [file_name] line by line.
Blanks lines (empty or only with spaces and tabs) are ignored.
Lines with '%' as the first char are ignores
*)
Lines with '%' as the first char are ignored. *)
val read: string -> string list
end
......@@ -42,22 +41,37 @@ module Pid_map : sig
exception MatchNotInjective
val exists: (key -> 'a -> bool) -> 'a t -> bool
val union_if: int t -> int t -> int t
end
end
(* ================================================================================ *)
(* [Gid] describes identifier used in full graphs *)
module Gid : sig type t = int end
(* ================================================================================ *)
(* [Gid_map] is the map used in full graphs *)
module Gid_map : Map.S with type key = Gid.t
(* ================================================================================ *)
(* [Array_] contains additional functions on the caml [array] type. *)
module Array_: sig
(* [dicho_mem elt array] returns true iff [elt] belongs to [array].
Warning: the array MUST be sorted and without duplicates. *)
val dicho_mem: 'a -> 'a array -> bool
(* dichotomic search: the array MUST be sorted and without duplicates. Not found can be raised *)
(* [dicho_find elt array] returns the index of the position where [elt] is found in the [array].
[Not found] is raised if [elt] is not in [array].
Warning: the array MUST be sorted and without duplicates. *)
val dicho_find: 'a -> 'a array -> int
(* [dicho_find_assoc key array] returns the value associated with [key] in the assoc [array].
[Not found] is raised if [key] is not defined in [array].
Warning: the array MUST be sorted (with respect to the first component) and without duplicates. *)
val dicho_find_assoc: 'a -> ('a*'b) array -> int
end
(* ================================================================================ *)
(* [List_] contains additional functions on the caml [list] type. *)
module List_: sig
(** [rm elt list] removes the first occurence of [elt] in [list]. [Not_found] can be raised. *)
val rm: 'a -> 'a list -> 'a list
......
......@@ -61,6 +61,9 @@ let load_grs ?doc_output_dir file =
| Error.Bug (msg, loc) -> raise (Bug (msg,loc))
| exc -> raise (Bug (sprintf "[Libgrew.load_grs] UNCATCHED EXCEPTION: %s" (Printexc.to_string exc), None))
let to_sentence ?main_feat gr =
let graph = gr.Instance.graph in
G_graph.to_sentence ?main_feat graph
let get_sequence_names grs = Grs.sequence_names grs
......
......@@ -46,6 +46,7 @@ val load_grs : ?doc_output_dir:string -> string -> Grs.t
*)
val get_sequence_names: Grs.t -> string list
val to_sentence: ?main_feat:string -> Instance.t -> string
val empty_gr : Instance.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