grew_fs.mli 3.62 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
open Grew_ast
pj2m's avatar
pj2m committed
13

14 15 16 17
module Domain: sig
  val reset: unit -> unit

  val init: Ast.domain -> unit
18 19

  val feature_names: unit -> string list option
pj2m's avatar
pj2m committed
20 21
end

bguillaum's avatar
Typos  
bguillaum committed
22
(* [G_fs] define the feature srtuctures that are used in graphs *)
23
module G_fs: sig
pj2m's avatar
pj2m committed
24 25
  type t

26 27 28 29 30 31 32 33 34
  val empty: t
  
  (** [set_feat feature_name atom t] adds the feature ([feature_name],[atom]) in [t].
      If [t] already contains a feature named [feature_name], the old value is erased by the new one. *)
  val set_feat: ?loc:Loc.t -> string -> string -> t ->  t

  (** [del_feat feature_name t] remove the feature with name [feature_name] in [t].
      If [t] does not contain such a feature, [t] is returned unchanged. *)
  val del_feat:  string -> t ->  t
bguillaum's avatar
bguillaum committed
35

bguillaum's avatar
bguillaum committed
36
  (** [get_string_atom f t] returns [Some v] if the fs [t] contains the feature (f,v).
37
      It returns [None] if there is no feature named [f] in [t] *)
bguillaum's avatar
bguillaum committed
38
  val get_string_atom: string -> t -> string option
bguillaum's avatar
bguillaum committed
39

bguillaum's avatar
bguillaum committed
40
  val get_float_feat: string -> t -> float option
41
  val to_gr: t -> string
42
  val to_dot: ?decorated_feat:(string * string list) -> ?main_feat: string -> t -> string
43
  val to_word: ?main_feat: string -> t -> string
44
  val to_dep: ?decorated_feat:(string * string list) -> ?position:float -> ?main_feat: string -> ?filter: string list -> t -> string
bguillaum's avatar
bguillaum committed
45
  val to_raw: t -> (string * string) list
bguillaum's avatar
bguillaum committed
46
  val to_conll: ?exclude: string list -> t -> string
47

bguillaum's avatar
bguillaum committed
48
  (** [get_annot_info fs] searches for a feature with name starting with "__".
bguillaum's avatar
bguillaum committed
49
      It returns the feature_name without the prefix "__"
bguillaum's avatar
bguillaum committed
50
      raise an [Build] exception if there is more than one such feature. *)
bguillaum's avatar
bguillaum committed
51
  val get_annot_info: t -> string option
bguillaum's avatar
bguillaum committed
52

53 54 55
  val to_string: t -> string

  val build: Ast.feature list -> t
bguillaum's avatar
bguillaum committed
56

57
  val of_conll: ?loc:Loc.t -> Conll.line -> t
bguillaum's avatar
bguillaum committed
58

59 60 61 62 63 64 65
  (** [unif t1 t2] returns [Some t] if [t] is the unification of two graph feature structures
      [None] is returned if the two feature structures cannot be unified. *)
  val unif: t -> t -> t option
end
  
module P_fs: sig
  type t
bguillaum's avatar
bguillaum committed
66

67 68 69 70 71
  val empty: t
  
  val build: ?pat_vars: string list -> Ast.feature list -> t
  
  val to_string: t -> string
pj2m's avatar
pj2m committed
72

73
  val to_dep: ?filter: string list -> (string list * string list) -> t -> string
bguillaum's avatar
bguillaum committed
74

75
  val to_dot: t -> string
pj2m's avatar
pj2m committed
76

77
  val feat_list: t -> string list
bguillaum's avatar
bguillaum committed
78

79
  exception Fail
pj2m's avatar
pj2m committed
80

81 82 83 84 85 86
  (** [match_ ?param t gfs] tries to match the pattern fs [pfs] with the graph fs [gfs] 
      If [param] is [None], it returns [None] if matching succeeds and else raise [Fail].
      If [param] is [Some p], it returns [Some p'] if matching succeeds and else raise [Fail].
   *) 
  val match_: ?param:Lex_par.t -> t -> G_fs.t -> Lex_par.t option

87 88 89 90
  (** [check_position ?parma position pfs] checks wheter [pfs] is compatible with a node at [position].
      It returns [true] iff [pfs] has no requirement about position ok if the requirement is satisfied. *)
  val check_position: ?param:Lex_par.t -> float -> t -> bool

91
  val filter: t -> G_fs.t -> bool
bguillaum's avatar
bguillaum committed
92 93

  val unif: t -> t -> t
94
end