grew_utils.mli 4.32 KB
Newer Older
pj2m's avatar
pj2m committed
1 2

module IntSet : Set.S with type elt = int
3
module IntMap : Map.S with type key = int
pj2m's avatar
pj2m committed
4

5 6 7
module Pid : sig type t = int end

module Pid_map : sig
pj2m's avatar
pj2m committed
8 9 10 11 12 13 14
  include Map.S with type key = int
  exception MatchNotInjective
  val exists: (key -> 'a -> bool) -> 'a t -> bool
  val union_if: int t -> int t -> int t
  end

module StringMap : Map.S with type key = string
bguillaum's avatar
bguillaum committed
15
module StringSet : Set.S with type elt = string
pj2m's avatar
pj2m committed
16 17 18 19 20 21 22 23 24 25 26

module Loc: sig
  type t = string * int 

  val to_string: t -> string
end



module File: sig 
  val write: string -> string -> unit
bguillaum's avatar
bguillaum committed
27 28

  val read: string -> string list
pj2m's avatar
pj2m committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
end

module Array_: sig
  val dicho_mem: 'a -> 'a array -> bool

  (* dichotomic search: the array MUST be sorted and without duplicates. Not found can be raised *)
  val dicho_find: 'a -> 'a array -> int
  val dicho_find_assoc: 'a -> ('a*'b) array -> int
end

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
  val opt: 'a option list -> 'a list

  val opt_map: ('a -> 'b option) -> 'a list -> 'b list

  val flat_map: ('a -> 'b list) -> 'a list -> 'b list
  (* remove [elt] from [list]. raise Not_found if [elt] is not in [list] *)      
  val remove: 'a -> 'a list -> 'a list

  val foldi_left: (int -> 'a -> 'b -> 'a) -> 'a -> 'b list -> 'a

  (** [disjoint_list] returns true iff the two strictly ordered list are disjoint *)
  val sort_disjoint: 'a list -> 'a list -> bool

  val to_string: ('a -> string) -> string -> 'a list -> string

  val iteri: (int -> 'a -> unit) -> 'a list -> unit

  val mapi: (int -> 'a -> 'b) -> 'a list -> 'b list

61 62
  val sort_mem: 'a -> 'a list -> bool

pj2m's avatar
pj2m committed
63 64 65 66 67 68 69 70 71 72 73 74 75
  (* Insert an element in a sorted list. *)
  val sort_insert: 'a -> 'a list -> 'a list

  (* Insert an element in a usort list. Return Some l or None if the element is already in the list *)
  val usort_insert: ?compare:('a -> 'a -> int) -> 'a -> 'a list -> 'a list option

  val sort_is_empty_inter: 'a list -> 'a list -> bool
  val sort_inter: 'a list -> 'a list -> 'a list
  val sort_disjoint_union: ?compare:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
  val sort_include: 'a list -> 'a list -> bool
  val sort_included_diff: 'a list -> 'a list -> 'a list
  val sort_diff: 'a list -> 'a list -> 'a list

76
  val foldi_left: (int -> 'a -> 'b -> 'a) -> 'a -> 'b list -> 'a
pj2m's avatar
pj2m committed
77 78 79 80 81 82
end

(* module Massoc implements multi-association data: keys are int and the same key can be
associated with a set of values *)
module Massoc: sig
  type 'a t
83

pj2m's avatar
pj2m committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
  val empty: 'a t

  (* an empty list returned if the key is undefined *) 
  val assoc: int -> 'a t -> 'a list

  val is_empty: 'a t -> bool

  val to_string: ('a -> string) -> 'a t -> string

  val iter: (int -> 'a -> unit) -> 'a t -> unit

  val add: int -> 'a -> 'a t -> 'a t option

  val fold_left: ('b -> int -> 'a -> 'b) -> 'b -> 'a t -> 'b

  (* raise Not_found if no (key,elt) *)
  val remove: int -> 'a -> 'a t -> 'a t
      
  (* raise Not_found if no (key,elt) *)
  val remove_key: int -> 'a t -> 'a t

  (* [mem key value t ] test if the couple (key, value) is in the massoc [t]. *)
  val mem: int -> 'a -> 'a t -> bool

  (* mem_key key t] tests is [key] is associated to at least one value in [t]. *)
  val mem_key: int -> 'a t -> bool

  exception Not_disjoint
  val disjoint_union: 'a t -> 'a t -> 'a t 

  exception Duplicate
  val merge_key: int -> int -> 'a t -> 'a t

  val exists: (int -> 'a -> bool) -> 'a t -> bool
end
    
bguillaum's avatar
bguillaum committed
120

pj2m's avatar
pj2m committed
121 122

module Error: sig
bguillaum's avatar
bguillaum committed
123 124 125 126
  exception Build of (string * Loc.t option)
  exception Run of (string * Loc.t option)
  exception Bug of (string * Loc.t option)

pj2m's avatar
pj2m committed
127 128
  val build: ?loc: Loc.t -> ('a, unit, string, 'b) format4 -> 'a
  val run: ?loc: Loc.t -> ('a, unit, string, 'b) format4 -> 'a
bguillaum's avatar
bguillaum committed
129
  val bug: ?loc: Loc.t -> ('a, unit, string, 'b) format4 -> 'a
pj2m's avatar
pj2m committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
end




module Id: sig
  type name = string
  type t = int

  type table = name array

  (* [Stop] is raised if [string] is not in [table] *)
  val build: ?loc:Loc.t -> name -> table -> t

  val build_opt: name -> table -> t option 
end

147 148 149 150
module Html: sig
  val enter: out_channel -> ?title: string -> ?header: string -> string -> unit
  val leave: out_channel -> unit
end
bguillaum's avatar
bguillaum committed
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165

module Conll: sig
  type line = {
      num: int;
      phon: string;
      lemma: string;
      pos1: string;
      pos2: string;
      morph: (string * string) list;
      gov: int;
      dep_lab: string;
    }
        
  val parse: string -> line
end