libgrew.mli 7.76 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
bguillaum's avatar
bguillaum committed
28
  val feature_names: t -> string list
bguillaum's avatar
bguillaum committed
29 30 31 32 33 34 35 36 37
end

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

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

  (** [load_pattern domain description] returns the pattern described in the [descriprion] string *)
  val parse: ?domain:Domain.t -> string -> t
bguillaum's avatar
bguillaum committed
42 43 44 45 46 47 48
end

(* ==================================================================================================== *)
(** {2 Matching} *)
(* ==================================================================================================== *)
module Matching: sig
  type t
49 50

  val to_python: Pattern.t -> Grew_graph.G_graph.t -> t -> string
bguillaum's avatar
bguillaum committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
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
66
(** {2 Graph} *)
bguillaum's avatar
bguillaum committed
67 68
(* ==================================================================================================== *)
module Graph : sig
bguillaum's avatar
bguillaum committed
69

bguillaum's avatar
bguillaum committed
70 71 72 73
  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
74
      @raise File_not_found if the file doesn't exists. *)
bguillaum's avatar
bguillaum committed
75
  val load: ?domain:Domain.t -> string -> t
bguillaum's avatar
bguillaum committed
76

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

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

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

83 84 85
  val of_pst: ?domain:Domain.t -> string -> t
  val sentence_of_pst: ?domain:Domain.t -> string -> string

bguillaum's avatar
bguillaum committed
86
  val to_sentence: ?main_feat:string -> t -> string
bguillaum's avatar
bguillaum committed
87

bguillaum's avatar
bguillaum committed
88
  val to_dot : ?domain:Domain.t -> ?main_feat:string -> ?deco:Deco.t -> t -> string
89

bguillaum's avatar
bguillaum committed
90
  val to_dep : ?domain:Domain.t -> ?filter: string list -> ?main_feat:string -> ?deco:Deco.t -> t -> string
91

bguillaum's avatar
bguillaum committed
92
  val to_gr: ?domain:Domain.t -> t -> string
bguillaum's avatar
bguillaum committed
93

bguillaum's avatar
bguillaum committed
94
  val to_conll_string: ?domain:Domain.t -> t -> string
bguillaum's avatar
bguillaum committed
95

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

  val node_matching: Pattern.t -> t -> Matching.t -> (string * int) list
bguillaum's avatar
bguillaum committed
100
end
bguillaum's avatar
bguillaum committed
101

bguillaum's avatar
bguillaum committed
102
(* ==================================================================================================== *)
103
(** {2 Graph Rewriting System} *)
bguillaum's avatar
bguillaum committed
104 105
(* ==================================================================================================== *)
module Grs: sig
106

bguillaum's avatar
bguillaum committed
107 108
  type t
  val empty: t
109

bguillaum's avatar
bguillaum committed
110 111
  (** [load filename] loads a graph rewriting system from [filename]
      @raise Parsing_err if libgrew can't parse the file
112
      @raise File_not_found if the file doesn't exists *)
bguillaum's avatar
bguillaum committed
113
  val load: string -> t
114

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

bguillaum's avatar
bguillaum committed
118 119 120
  (** [build_html_doc ?corpus directory t]
      @[corpus] is a flag (default is [false]) for complete html doc with corpus sentence. *)
  val build_html_doc: ?corpus:bool -> string -> t -> unit
bguillaum's avatar
bguillaum committed
121

bguillaum's avatar
bguillaum committed
122
  val get_domain: t -> Domain.t option
bguillaum's avatar
bguillaum committed
123
end
bguillaum's avatar
bguillaum committed
124

bguillaum's avatar
bguillaum committed
125
(* ==================================================================================================== *)
bguillaum's avatar
bguillaum committed
126
(** {2 Rewrite history} *)
bguillaum's avatar
bguillaum committed
127 128
(* ==================================================================================================== *)
module Rewrite: sig
Bruno Guillaume's avatar
Bruno Guillaume committed
129

bguillaum's avatar
bguillaum committed
130 131
  type display = Libgrew_types.rew_display
  type history
bguillaum's avatar
bguillaum committed
132

133 134
  val set_max_depth_det: int -> unit
  val set_max_depth_non_det: int -> unit
bguillaum's avatar
bguillaum committed
135
  val set_debug_loop: unit -> unit
136

bguillaum's avatar
bguillaum committed
137 138 139 140 141 142
  (** [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 *)
  val display: gr:Graph.t -> grs:Grs.t -> seq:string -> display
bguillaum's avatar
bguillaum committed
143

bguillaum's avatar
bguillaum committed
144
  val set_timeout: float option -> unit
bguillaum's avatar
bguillaum committed
145

bguillaum's avatar
bguillaum committed
146
  val rewrite: gr:Graph.t -> grs:Grs.t -> seq:string -> history
bguillaum's avatar
bguillaum committed
147

148
  val simple_rewrite: gr:Graph.t -> grs:Grs.t -> strat:string -> Graph.t list
149

bguillaum's avatar
bguillaum committed
150
  val is_empty: history -> bool
bguillaum's avatar
bguillaum committed
151

bguillaum's avatar
bguillaum committed
152
  val num_sol: history -> int
bguillaum's avatar
bguillaum committed
153

bguillaum's avatar
bguillaum committed
154
  val write_stat: string -> history -> unit
bguillaum's avatar
bguillaum committed
155

bguillaum's avatar
bguillaum committed
156
  val save_gr: ?domain:Domain.t -> string -> history -> unit
bguillaum's avatar
bguillaum committed
157

bguillaum's avatar
bguillaum committed
158
  val save_conll: ?domain:Domain.t -> string -> history -> unit
bguillaum's avatar
bguillaum committed
159

bguillaum's avatar
bguillaum committed
160 161 162
  (** [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. *)
bguillaum's avatar
bguillaum committed
163
  val save_full_conll: ?domain:Domain.t -> string -> history -> int
bguillaum's avatar
bguillaum committed
164

bguillaum's avatar
bguillaum committed
165
  val save_det_gr: ?domain:Domain.t -> string -> history -> unit
bguillaum's avatar
bguillaum committed
166

bguillaum's avatar
bguillaum committed
167 168
  val save_index: dirname:string -> base_names: string list -> unit

bguillaum's avatar
bguillaum committed
169 170
  val save_index: dirname:string -> base_names: string list -> unit

bguillaum's avatar
bguillaum committed
171
  val save_det_conll: ?domain:Domain.t -> ?header:string -> string -> history -> unit
bguillaum's avatar
bguillaum committed
172

bguillaum's avatar
bguillaum committed
173
  val det_dep_string: ?domain:Domain.t -> history -> string option
bguillaum's avatar
bguillaum committed
174

bguillaum's avatar
bguillaum committed
175
  val conll_dep_string: ?domain:Domain.t -> ?keep_empty_rh:bool -> history -> string option
bguillaum's avatar
bguillaum committed
176

177
  val save_index: dirname:string -> base_names: string array -> unit
pj2m's avatar
pj2m committed
178

bguillaum's avatar
bguillaum committed
179
  val write_annot: ?domain:Domain.t -> title:string -> string -> string -> (string * history) list -> unit
180

bguillaum's avatar
bguillaum committed
181
  val write_html: ?domain:Domain.t -> ?no_init: bool -> ?out_gr: bool -> ?filter: string list -> ?main_feat: string -> ?dot: bool -> header: string -> ?graph_file: string -> history -> string ->  unit
pj2m's avatar
pj2m committed
182

bguillaum's avatar
bguillaum committed
183
  val error_html: ?domain:Domain.t -> ?no_init:bool -> ?main_feat:string -> ?dot: bool -> header: string -> string -> ?init:Graph.t -> string -> unit
bguillaum's avatar
bguillaum committed
184

185
  val make_index: title: string -> grs_file: string -> html: bool -> grs: Grs.t -> seq: string -> input_dir: string -> output_dir: string -> base_names: string array -> unit
186

bguillaum's avatar
bguillaum committed
187 188
  val html_sentences: title:string -> string -> (bool * string * int * string) list -> unit
end