grew_grs.mli 4.17 KB
Newer Older
bguillaum's avatar
bguillaum committed
1 2 3 4 5 6 7 8 9 10
(**********************************************************************************)
(*    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                                                   *)
(**********************************************************************************)

bguillaum's avatar
bguillaum committed
11
open Grew_base
12
open Grew_types
13 14
open Grew_ast
open Grew_domain
bguillaum's avatar
bguillaum committed
15 16
open Grew_graph
open Grew_rule
bguillaum's avatar
bguillaum committed
17

bguillaum's avatar
bguillaum committed
18
(* ================================================================================ *)
pj2m's avatar
pj2m committed
19 20 21
module Rewrite_history: sig
  type t = {
      instance: Instance.t;
22
      module_name: string;
pj2m's avatar
pj2m committed
23 24 25
      good_nf: t list;
    }

26 27
  val get_graphs: t -> G_graph.t list

bguillaum's avatar
bguillaum committed
28
  val is_empty: t -> bool
bguillaum's avatar
bguillaum committed
29 30

  val num_sol: t -> int
31

bguillaum's avatar
bguillaum committed
32 33 34 35 36
  (** [save_nfs ?main_feat base_name t] does two things:
      - write PNG files of normal forms
      - returns a list of couples (rules, file)
  *)
  val save_nfs:
bguillaum's avatar
bguillaum committed
37
    ?domain:Domain.t ->
38 39
    ?filter: string list ->
    ?main_feat: string ->
bguillaum's avatar
bguillaum committed
40
    dot: bool ->
41 42
    string ->
    t ->
bguillaum's avatar
bguillaum committed
43
    ((string * string list) list * string) list
44

45 46
  (** [save_gr base_name t] saves one gr_file for each normal form defined in [t].
      Output files are named according to [base_name] and the Gorn adress in the rewriting tree. *)
bguillaum's avatar
bguillaum committed
47 48
  val save_gr: ?domain:Domain.t -> string -> t -> unit
  val save_conll: ?domain:Domain.t -> string -> t -> unit
49

50
  (** [save_full_conll base_name t] saves one conll_file for each normal form defined in [t].
51 52
      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
53
  val save_full_conll: ?domain:Domain.t -> string -> t -> int
54

55 56
  (** [save_det_gr base_name t] supposes that the current GRS is deterministic.
      It writes exactly one output file named [base_name].gr with the unique normal form. *)
bguillaum's avatar
bguillaum committed
57 58
  val save_det_gr: ?domain:Domain.t ->string -> t -> unit
  val save_det_conll: ?domain:Domain.t -> ?header:string -> string -> t -> unit
bguillaum's avatar
bguillaum committed
59

bguillaum's avatar
bguillaum committed
60
  val det_dep_string: ?domain:Domain.t -> t -> string option
bguillaum's avatar
bguillaum committed
61

bguillaum's avatar
bguillaum committed
62
  val conll_dep_string: ?domain:Domain.t -> ?keep_empty_rh:bool -> t -> string option
bguillaum's avatar
bguillaum committed
63
end (* module Rewrite_history *)
pj2m's avatar
pj2m committed
64

bguillaum's avatar
bguillaum committed
65
(* ================================================================================ *)
bguillaum's avatar
bguillaum committed
66 67 68 69
module Modul: sig
  type t = {
    name: string;
    rules: Rule.t list;
70
    deterministic: bool;
bguillaum's avatar
bguillaum committed
71 72
    loc: Loc.t;
  }
Bruno Guillaume's avatar
Bruno Guillaume committed
73 74

  val to_json: ?domain:Domain.t -> t -> Yojson.Basic.json
bguillaum's avatar
bguillaum committed
75
end (* module Modul *)
pj2m's avatar
pj2m committed
76

bguillaum's avatar
bguillaum committed
77
(* ================================================================================ *)
78
module Old_grs: sig
pj2m's avatar
pj2m committed
79 80
  type t

bguillaum's avatar
bguillaum committed
81
  val empty: t
82

bguillaum's avatar
bguillaum committed
83 84
  val get_modules: t -> Modul.t list

bguillaum's avatar
bguillaum committed
85 86
  val get_ast: t -> Ast.grs

bguillaum's avatar
bguillaum committed
87
  val get_domain: t -> Domain.t option
88

bguillaum's avatar
bguillaum committed
89 90
  val get_filename: t -> string

91
  val sequence_names: t -> string list
pj2m's avatar
pj2m committed
92

bguillaum's avatar
bguillaum committed
93
  val domain_build: Ast.domain -> Domain.t
94

bguillaum's avatar
bguillaum committed
95 96
  (** [build filename] returns the GRS defined in the file [filename] *)
  val build: string -> t
pj2m's avatar
pj2m committed
97

98
  val rewrite: t -> string -> G_graph.t -> Rewrite_history.t
pj2m's avatar
pj2m committed
99

100 101 102
  val simple_rewrite: t -> string -> G_graph.t -> G_graph.t list


bguillaum's avatar
bguillaum committed
103
  (* only external structure is returned, each edge contains a "dummy" big_step *)
104
  val build_rew_display: t -> string -> G_graph.t -> Libgrew_types.rew_display
bguillaum's avatar
bguillaum committed
105 106

  val rule_iter: (string -> Rule.t -> unit) -> t -> unit
bguillaum's avatar
bguillaum committed
107

bguillaum's avatar
bguillaum committed
108
(*  val modules_of_sequence: t -> string -> Modul.t list*)
Bruno Guillaume's avatar
Bruno Guillaume committed
109 110

  val to_json: t -> Yojson.Basic.json
bguillaum's avatar
bguillaum committed
111
end (* module Grs *)
112

113
module Grs : sig
114 115 116
  type t

  val load: string  -> t
117 118 119

  val dump: t -> unit

Bruno Guillaume's avatar
Bruno Guillaume committed
120
  val to_json: t -> Yojson.Basic.json
121
  val domain: t -> Domain.t option
Bruno Guillaume's avatar
Bruno Guillaume committed
122 123

  val simple_rewrite: t -> string -> G_graph.t -> G_graph.t list
124 125 126
  val det_rew_display: t -> string -> G_graph.t -> Libgrew_types.rew_display

  val get_strat_list: t -> string list
127 128
  val at_least_one: t -> string -> bool
  val at_most_one: t -> string -> bool
129 130 131
end

module Univ_grs : sig
132
  val load: string -> Grs.t
133
end