grew_grs.mli 3.36 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                                                   *)
(**********************************************************************************)

11
open Libgrew_utils
bguillaum's avatar
bguillaum committed
12 13 14
open Grew_graph
open Grew_rule
open Grew_ast
bguillaum's avatar
bguillaum committed
15

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

bguillaum's avatar
bguillaum committed
25
  val is_empty: t -> bool
bguillaum's avatar
bguillaum committed
26 27

  val num_sol: t -> int
28

bguillaum's avatar
bguillaum committed
29 30 31 32 33
  (** [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:
34 35
    ?filter: string list ->
    ?main_feat: string ->
bguillaum's avatar
bguillaum committed
36
    dot: bool ->
37 38
    string ->
    t ->
bguillaum's avatar
bguillaum committed
39
    ((string * string list) list * string) list
40

bguillaum's avatar
bguillaum committed
41
  (** [save_annot out_dir base_name t] writes a set of svg_file for an annotation folder. *)
bguillaum's avatar
bguillaum committed
42
  val save_annot: string -> string -> t -> (string * int * (string*float) * (string*float) * (float option * float option)) list
bguillaum's avatar
bguillaum committed
43

44 45
  (** [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. *)
46
  val save_gr: string -> t -> unit
bguillaum's avatar
bguillaum committed
47
  val save_conll: string -> t -> unit
48 49 50 51

  (** [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. *)
  val save_det_gr: string -> t -> unit
52
  val save_det_conll: ?header:string -> string -> t -> unit
bguillaum's avatar
bguillaum committed
53

bguillaum's avatar
bguillaum committed
54 55 56
  val det_dep_string: t -> string option

  val conll_dep_string: ?keep_empty_rh:bool -> t -> string option
pj2m's avatar
pj2m committed
57 58
end

59
(* ==================================================================================================== *)
bguillaum's avatar
bguillaum committed
60 61 62
module Modul: sig
  type t = {
    name: string;
63
    local_labels: (string * string list) array;
64
    suffixes: string list;
bguillaum's avatar
bguillaum committed
65 66 67 68 69
    rules: Rule.t list;
    filters: Rule.t list;
    confluent: bool;
    loc: Loc.t;
  }
70
end
pj2m's avatar
pj2m committed
71

72
(* ==================================================================================================== *)
pj2m's avatar
pj2m committed
73 74 75 76
module Grs: sig
  type t

  val empty:t
77

bguillaum's avatar
bguillaum committed
78 79
  val get_modules: t -> Modul.t list

bguillaum's avatar
bguillaum committed
80 81 82 83
  val get_ast: t -> Ast.grs

  val get_filename: t -> string

84
  val sequence_names: t -> string list
pj2m's avatar
pj2m committed
85

bguillaum's avatar
bguillaum committed
86 87
  (** [build filename] returns the GRS defined in the file [filename] *)
  val build: string -> t
pj2m's avatar
pj2m committed
88 89 90 91

  val rewrite: t -> string -> Instance.t -> Rewrite_history.t

  (* only externeal strucutre is returned, each edge contains a "dummy" big_step *)
bguillaum's avatar
bguillaum committed
92
  val build_rew_display: t -> string -> Instance.t -> Libgrew_types.rew_display
bguillaum's avatar
bguillaum committed
93 94

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

bguillaum's avatar
bguillaum committed
97
  val modules_of_sequence: t -> string -> Modul.t list
bguillaum's avatar
bguillaum committed
98
end