grew_fs.mli 3.98 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 12
open Conll

13
open Grew_base
14
open Grew_types
bguillaum's avatar
bguillaum committed
15
open Grew_ast
pj2m's avatar
pj2m committed
16

bguillaum's avatar
bguillaum committed
17 18
(* ================================================================================ *)
(* module [G_fs] defines the feature structures that are used in graphs *)
19
module G_fs: sig
pj2m's avatar
pj2m committed
20 21
  type t

22
  val empty: t
23

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

  (** [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
31

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

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

44
  (** [get_annot_info fs] searches for a feature with name starting with "__".
45
      It returns the feature_name without the prefix "__"
46
      raise an [Build] exception if there is more than one such feature. *)
47
  val get_annot_info: t -> string option
48

49 50
  val to_string: t -> string

51
  val build: Domain.t -> Ast.feature list -> t
bguillaum's avatar
bguillaum committed
52

53
  val of_conll: ?loc:Loc.t -> Domain.t -> Conll.line -> t
bguillaum's avatar
bguillaum committed
54

55 56 57
  (** [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
bguillaum's avatar
bguillaum committed
58
end (* module G_fs *)
59

bguillaum's avatar
bguillaum committed
60 61
(* ================================================================================ *)
(* module [P_fs] defines the feature structures that are used in patterns *)
62 63
module P_fs: sig
  type t
bguillaum's avatar
bguillaum committed
64

65
  val empty: t
66

67
  val build: Domain.t -> ?pat_vars: string list -> Ast.feature list -> t
68

69
  val to_string: t -> string
pj2m's avatar
pj2m committed
70

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

73
  val to_dot: t -> string
pj2m's avatar
pj2m committed
74

75
  val feat_list: t -> string list
bguillaum's avatar
bguillaum committed
76

77
  exception Fail
pj2m's avatar
pj2m committed
78

bguillaum's avatar
bguillaum committed
79
  (** [match_ ?param p_fs g_fs] tries to match the pattern fs [p_fs] with the graph fs [g_fs].
80 81
      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].
82
   *)
83 84
  val match_: ?param:Lex_par.t -> t -> G_fs.t -> Lex_par.t option

85 86 87 88
  (** [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

bguillaum's avatar
bguillaum committed
89
  exception Fail_unif
bguillaum's avatar
bguillaum committed
90
  (** [unif fs1 fs2] returns the unification of the two feature structures.
bguillaum's avatar
bguillaum committed
91
      It raises [Fail_unif] exception in case of Failure.
bguillaum's avatar
bguillaum committed
92
  *)
bguillaum's avatar
bguillaum committed
93
  val unif: t -> t -> t
bguillaum's avatar
bguillaum committed
94
end (* module P_fs *)