grew_types.mli 6.23 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(**********************************************************************************)
(*    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                                                   *)
(**********************************************************************************)

open Grew_base

type feature_name = string (* cat, num, ... *)
type feature_atom = string (* V, N, inf, ... *)
type feature_value = string (* V, 4, "free text", ... *)
type suffix = string

bguillaum's avatar
bguillaum committed
18
19
20
21
22
23
24

type value = String of string | Float of float

val string_of_value : value -> string

val conll_string_of_value : value -> string

25
26
27
28
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
(* ================================================================================ *)
(* [Pid] describes identifier used in pattern graphs *)
module Pid : sig
  type t = Pos of int | Neg of int
  val compare: t -> t -> int
  val to_id: t -> string
  val to_string: t -> string
end (* module Pid *)

(* ================================================================================ *)
(* [Pid_map] is the map used in pattern graphs *)
module Pid_map : sig
  include Map.S with type key = Pid.t

  val exists: (key -> 'a -> bool) -> 'a t -> bool
end (* module Pid_map *)

(* ================================================================================ *)
(* [Pid_set] *)
module Pid_set : Set.S with type elt = Pid.t

(* ================================================================================ *)
(* [Gid] describes identifier used in full graphs *)
module Gid : sig
  type t =
    | Old of int
    | New of (int * int) (* identifier for "created nodes" *)
    | Act of (int * string)  (* identifier for "activated nodes" *)

  val compare: t -> t -> int

  val to_string: t -> string
end (* module Gid *)

(* ================================================================================ *)
(* [Gid_map] is the map used in full graphs *)
module Gid_map : Map.S with type key = Gid.t

(* ================================================================================ *)
module Massoc_gid : S with type key = Gid.t

(* ================================================================================ *)
module Massoc_pid : S with type key = Pid.t

(* ================================================================================ *)
(** The module [Label] defines the type of atomic label edges *)
module Label : sig
  (* [decl] is the type for a label declaration: the name and a list of display options *)
  type decl = string * string list

  type t

  val init: decl list -> unit

  val to_string: ?locals:decl array -> t -> string

  val to_int: t -> int option

  val to_dep: ?deco:bool -> t -> string

  val to_dot: ?deco:bool -> t -> string

  val from_string: ?loc:Loc.t -> ?locals:decl array -> string -> t
end (* module Label *)

bguillaum's avatar
bguillaum committed
90
91
92
93
94
(* ================================================================================ *)
module Domain: sig
  type feature_spec =
    | Closed of feature_name * feature_atom list (* cat:V,N *)
    | Open of feature_name (* phon, lemma, ... *)
bguillaum's avatar
bguillaum committed
95
    | Num of feature_name (* position *)
bguillaum's avatar
bguillaum committed
96

bguillaum's avatar
bguillaum committed
97
98
  type t = feature_spec list
  val normalize_domain: t -> t
bguillaum's avatar
bguillaum committed
99
100
101

  val reset: unit -> unit

bguillaum's avatar
bguillaum committed
102
  val init: t -> unit
bguillaum's avatar
bguillaum committed
103
104
105
106
107
108

  val build: ?loc:Loc.t -> feature_name -> feature_atom list -> value list

  val build_one: ?loc:Loc.t -> feature_name -> feature_atom -> value

  val feature_names: unit -> string list option
109
110
111
112
113
114
115
116
117
118

  (** [check_feature_name ~loc feature_name] fails iff a domain is set and [feature_name] is not defined in the current domain. *)
  val check_feature_name: ?loc:Loc.t -> feature_name -> unit

  (** [check_feature ~loc feature_name feature_value] fails iff a domain is set and [feature_name,feature_value] is not defined in the current domain. *)
  val check_feature: ?loc:Loc.t -> feature_name -> feature_atom -> unit

  (** [is_open feature_name] returns [true] iff no domain is set or if [feature_name] is defined to be open in the current domain. *)
  val is_open: feature_name -> bool

119
120
  (** [sub fn1 fn2] returns [true] iff the domain of [fn1] is a subset if the domain of [fn2]. *)
  val sub: feature_name -> feature_name -> bool
bguillaum's avatar
bguillaum committed
121
122
end (* module Domain *)

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
(* ================================================================================ *)
module Conll: sig
  type line = {
    line_num: int;
    num: string;
    phon: string;
    lemma: string;
    pos1: string;
    pos2: string;
    morph: (string * string) list;
    deps: (string * string ) list;
  }

  val line_to_string: line -> string

  val root:line

  val load: string -> line list

  val parse: string -> (int * string) list -> line list

  val compare: line -> line -> int
end (* module Conll *)

(* ================================================================================ *)
bguillaum's avatar
bguillaum committed
148
(** module for rules that are lexically parametrized *)
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
module Lex_par: sig
  type t

  val empty:t
  val append: t -> t -> t

  val dump: t -> unit

  (** [from_lines filename nb_pattern_var nb_command_var strings] *)
  val from_lines: ?loc: Loc.t -> int -> int -> string list -> t

  (** [load ?loc local_dir_name nb_pattern_var nb_command_var file] *)
  val load: ?loc: Loc.t -> string -> int -> int -> string -> t

  (** [filter index atom t] returns the subset of [t] which contains only entries
      which refers to [atom] at the [index]^th pattern_var.
      [None] is returnes if no such entry s founded.
   *)
  val filter: int -> string -> t -> t option

  (** [get_param_value index t] returns the [index]^th param_var. *)
  val get_param_value: int -> t -> string

  (** [get_command_value index t] supposes that [t] contains iny one element.
      It returns the [index]^th command_var. *)
  val get_command_value: int -> t -> string
end (* module Lex_par *)

bguillaum's avatar
bguillaum committed
177
178
179
180
181
182
183
184
(* ================================================================================ *)
module Concat_item : sig
  type t =
  | Feat of (Gid.t * feature_name)
  | String of string
end (* module Concat_item *)


185