libgrew.mli 7.29 KB
Newer Older
bguillaum's avatar
bguillaum committed
1 2 3 4 5 6 7 8 9
(**********************************************************************************)
(*    Libcaml-grew - a Graph Rewriting library dedicated to NLP applications      *)
(*                                                                                *)
(*    Copyright 2011-2013 Inria, Université de Lorraine                           *)
(*                                                                                *)
(*    Webpage: http://grew.loria.fr                                               *)
(*    License: CeCILL (see LICENSE folder or "http://www.cecill.info")            *)
(*    Authors: see AUTHORS file                                                   *)
(**********************************************************************************)
pj2m's avatar
pj2m committed
10

11 12
open Conll

bguillaum's avatar
bguillaum committed
13
val libgrew_debug_mode: unit -> unit
bguillaum's avatar
bguillaum committed
14
val get_version: unit -> string
bguillaum's avatar
bguillaum committed
15 16

(* ==================================================================================================== *)
bguillaum's avatar
bguillaum committed
17
(** {2 Exceptions} *)
bguillaum's avatar
bguillaum committed
18
(* ==================================================================================================== *)
19 20
exception Error of string
exception Bug of string
pj2m's avatar
pj2m committed
21

bguillaum's avatar
bguillaum committed
22
(* ==================================================================================================== *)
23
(** {2 Domain} *)
bguillaum's avatar
bguillaum committed
24 25 26 27
(* ==================================================================================================== *)
module Domain : sig
  type t
  val load: string -> t
28
  val dump: t option -> unit
bguillaum's avatar
bguillaum committed
29
  val feature_names: t -> string list
bguillaum's avatar
bguillaum committed
30 31 32 33 34 35 36 37 38
end

(* ==================================================================================================== *)
(** {2 Patterns} *)
(* ==================================================================================================== *)
module Pattern : sig
  type t

  (** [load_pattern domain filename] returns the pattern described in the file *)
bguillaum's avatar
bguillaum committed
39
  val load: ?domain:Domain.t -> string -> t
40 41 42

  (** [load_pattern domain description] returns the pattern described in the [descriprion] string *)
  val parse: ?domain:Domain.t -> string -> t
43

44
  val pid_name_list: t -> string list
45

bguillaum's avatar
bguillaum committed
46 47 48 49 50 51 52
end

(* ==================================================================================================== *)
(** {2 Matching} *)
(* ==================================================================================================== *)
module Matching: sig
  type t
53 54

  val to_python: Pattern.t -> Grew_graph.G_graph.t -> t -> string
bguillaum's avatar
bguillaum committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
end

(* ==================================================================================================== *)
(** {2 Deco} *)
(* ==================================================================================================== *)
module Deco: sig
  type t = Grew_graph.G_deco.t

  (** [build pattern matching] returns the deco to be used in the graphical representation.
      WARNING: the function supposes that [matching] was find with the given [pattern]! *)
  val build: Pattern.t -> Matching.t -> t
end


(* ==================================================================================================== *)
bguillaum's avatar
bguillaum committed
70
(** {2 Graph} *)
bguillaum's avatar
bguillaum committed
71 72
(* ==================================================================================================== *)
module Graph : sig
bguillaum's avatar
bguillaum committed
73

bguillaum's avatar
bguillaum committed
74 75 76 77
  type t = Grew_graph.G_graph.t
  (** get a graph from a file either in 'gr' or 'conll' format.
      File extension should be '.gr' or '.conll'.
      @raise Parsing_err if libgrew can't parse the file
78
      @raise File_not_found if the file doesn't exists. *)
bguillaum's avatar
bguillaum committed
79
  val load: ?domain:Domain.t -> string -> t
bguillaum's avatar
bguillaum committed
80

bguillaum's avatar
bguillaum committed
81
  val of_gr: ?domain:Domain.t -> ?grewpy:bool -> string -> t
82

bguillaum's avatar
bguillaum committed
83
  val of_conll: ?domain:Domain.t -> Conll.t -> t
bguillaum's avatar
bguillaum committed
84

bguillaum's avatar
bguillaum committed
85
  val of_brown: ?domain:Domain.t -> ?sentid:string -> string -> t
bguillaum's avatar
bguillaum committed
86

87
  val of_pst: ?domain:Domain.t -> string -> t
88

89 90
  val sentence_of_pst: ?domain:Domain.t -> string -> string

91

92
  val to_sentence: ?main_feat:string -> ?deco:Deco.t -> t -> string
bguillaum's avatar
bguillaum committed
93

94
  val to_dot : ?main_feat:string -> ?deco:Deco.t -> t -> string
95

96
  val to_dep : ?filter: (string -> bool) -> ?main_feat:string -> ?deco:Deco.t -> t -> string
97

98
  val to_gr: t -> string
bguillaum's avatar
bguillaum committed
99

100
  val to_conll: t -> Conll.t
101

102
  val to_conll_string: t -> string
bguillaum's avatar
bguillaum committed
103

bguillaum's avatar
bguillaum committed
104
  (** [search_pattern pattern graph] returns the list of the possible matching of [pattern] in [graph] *)
bguillaum's avatar
bguillaum committed
105
  val search_pattern: ?domain:Domain.t -> Pattern.t -> t -> Matching.t list
106

107
  val node_matching: Pattern.t -> t -> Matching.t -> (string * float) list
bguillaum's avatar
bguillaum committed
108
end
bguillaum's avatar
bguillaum committed
109

110
(* OBSOLETE
bguillaum's avatar
bguillaum committed
111
(* ==================================================================================================== *)
112
(** {2 Graph Rewriting System} *)
bguillaum's avatar
bguillaum committed
113
(* ==================================================================================================== *)
114
module Old_grs: sig
115

bguillaum's avatar
bguillaum committed
116 117
  type t
  val empty: t
118

bguillaum's avatar
bguillaum committed
119 120
  (** [load filename] loads a graph rewriting system from [filename]
      @raise Parsing_err if libgrew can't parse the file
121
      @raise File_not_found if the file doesn't exists *)
bguillaum's avatar
bguillaum committed
122
  val load: string -> t
123

bguillaum's avatar
bguillaum committed
124 125
  (** [get_sequence_names t] returns the list of sequence names defined in a GRS *)
  val get_sequence_names: t -> string list
126

bguillaum's avatar
bguillaum committed
127
  val get_domain: t -> Domain.t option
128 129

  val to_json: t -> string
bguillaum's avatar
bguillaum committed
130
end
131
*)
bguillaum's avatar
bguillaum committed
132

133 134 135
(* ==================================================================================================== *)
(** {2 New Graph Rewriting System} *)
(* ==================================================================================================== *)
136
module Grs : sig
137 138 139
  type t

  val load: string -> t
Bruno Guillaume's avatar
Bruno Guillaume committed
140
  val load_old: string -> t
141 142 143 144

  val dump: t -> unit

  val domain: t -> Domain.t option
145 146 147

  val to_json: t -> string

148
  val get_strat_list: t -> string list
149 150
end

bguillaum's avatar
bguillaum committed
151
(* ==================================================================================================== *)
bguillaum's avatar
bguillaum committed
152
(** {2 Rewrite history} *)
bguillaum's avatar
bguillaum committed
153 154
(* ==================================================================================================== *)
module Rewrite: sig
155

bguillaum's avatar
bguillaum committed
156 157
  type display = Libgrew_types.rew_display
  type history
bguillaum's avatar
bguillaum committed
158

159
  val size: display -> int
160 161
  val set_max_depth_det: int -> unit
  val set_max_depth_non_det: int -> unit
bguillaum's avatar
bguillaum committed
162
  val set_debug_loop: unit -> unit
163

bguillaum's avatar
bguillaum committed
164 165 166 167 168
  (** [display gr grs seq] builds the [display] (datatype used by the GUI) given by
      the rewriting of graph [gr] with the sequence [seq] of [grs].
      @param gr the grapth to rewrite
      @param grs the graph rewriting system
      @param seq the name of the sequence to apply *)
169
  val display: gr:Graph.t -> grs:Grs.t -> strat:string -> display
170

171 172
  val at_least_one: grs:Grs.t -> strat:string -> bool
  val at_most_one: grs:Grs.t -> strat:string -> bool
bguillaum's avatar
bguillaum committed
173

bguillaum's avatar
bguillaum committed
174
  val set_timeout: float option -> unit
bguillaum's avatar
bguillaum committed
175

176
  val simple_rewrite: gr:Graph.t -> grs:Grs.t -> strat:string -> Graph.t list
177

bguillaum's avatar
bguillaum committed
178
  val is_empty: history -> bool
bguillaum's avatar
bguillaum committed
179

bguillaum's avatar
bguillaum committed
180
  val num_sol: history -> int
bguillaum's avatar
bguillaum committed
181

182
  val save_gr: string -> history -> unit
bguillaum's avatar
bguillaum committed
183

184
  val save_conll: string -> history -> unit
bguillaum's avatar
bguillaum committed
185

bguillaum's avatar
bguillaum committed
186 187 188
  (** [save_full_conll base_name rh] saves one conll_file for each normal form defined in [rh].
      Output files are named according to [base_name] and a secondary index after "__".
      The number of conll file produced is returned. *)
189
  val save_full_conll: string -> history -> int
bguillaum's avatar
bguillaum committed
190

191
  val save_det_gr: string -> history -> unit
bguillaum's avatar
bguillaum committed
192

bguillaum's avatar
bguillaum committed
193 194
  val save_index: dirname:string -> base_names: string list -> unit

bguillaum's avatar
bguillaum committed
195 196
  val save_index: dirname:string -> base_names: string list -> unit

197
  val save_det_conll: ?header:string -> string -> history -> unit
bguillaum's avatar
bguillaum committed
198

199
  val det_dep_string: history -> string option
bguillaum's avatar
bguillaum committed
200

201
  val conll_dep_string: ?keep_empty_rh:bool -> history -> string option
202

203
  val save_index: dirname:string -> base_names: string array -> unit
bguillaum's avatar
bguillaum committed
204
end